├── .gitignore ├── dylib ├── floatpatch │ ├── floatResultPatch.go │ └── floatResultPatch_amd64.s └── dylib_windows.go ├── README.md ├── lcl ├── stream.go ├── api │ ├── bitmapdef.go │ ├── finalizerOff.go │ ├── mousedef.go │ ├── finalizerOn.go │ ├── screendef.go │ ├── dylib_nontempdll.go │ ├── printerdef.go │ ├── importdef_linux.go │ ├── formdef.go │ ├── memorystreamdef.go │ ├── applicationdef.go │ ├── importFuncsChartStyleEnumerator.go │ ├── importFuncsChartTextOut.go │ ├── applicationformresdef.go │ ├── importdef_darwin.go │ ├── dylib_nonmemory.go │ ├── dylib.go │ ├── importFuncsChartSeriesList.go │ ├── importFuncsChartStyles.go │ ├── importFuncsBrowser.go │ ├── importFuncsChartErrorBar.go │ ├── importFuncsObject.go │ ├── importFuncsSynBatSyn.go │ ├── importFuncsException.go │ ├── importFuncsSynBasicSyn.go │ ├── imagelistdef.go │ ├── importFuncsSynTexSyn.go │ ├── clipboarddef.go │ ├── importFuncsSynPhpSyn.go │ ├── importFuncsSynCssSyn.go │ ├── intf_posix.go │ ├── importFuncsSynCppSyn.go │ ├── importFuncsSynJavaSyn.go │ ├── importFuncsChartShadow.go │ ├── importFuncsSynJScriptSyn.go │ ├── importFuncsIconOptions.go │ ├── importFuncsMouse.go │ ├── stdstr.go │ ├── importFuncsSynGutter.go │ ├── importFuncsChartArrow.go │ ├── importFuncsAnchorSide.go │ ├── importFuncsChartAxisIntervalParams.go │ ├── canvasdef.go │ ├── importFuncsSynShellSyn.go │ ├── importFuncsChartRange.go │ ├── importFuncsSynHtmlSyn.go │ ├── importFuncsSynPythonSyn.go │ ├── importFuncsCollectionItem.go │ ├── importFuncsSeriesPointer.go │ ├── importFuncsBrush.go │ ├── importFuncsSynXmlSyn.go │ ├── importFuncsChartSeriesLegend.go │ └── importFuncsMonitor.go ├── rtl │ ├── rtl_posix.go │ ├── consts_windows.go │ ├── consts_posix.go │ ├── init_windows.go │ ├── version │ │ ├── init.go │ │ ├── osversion.go │ │ └── osversion_darwin.go │ ├── guid.go │ ├── rtl_windows.go │ ├── init_posix.go │ ├── intf.go │ └── intf_windows.go ├── win │ ├── oleaut32dll.go │ ├── psapidll.go │ ├── ole32dll.go │ ├── enums.go │ ├── advapi32dll.go │ ├── netapi32dll.go │ ├── init.go │ ├── msvcrtdll.go │ ├── tlhelp32.go │ ├── gdi32dll.go │ ├── shell32dll.go │ └── structs.go ├── finalizerOff.go ├── vars.go ├── customtypes.go ├── types │ ├── other.go │ ├── message_windows.go │ ├── message_posix.go │ ├── window_darwin.go │ ├── cursors.go │ └── consts.go ├── debug.go ├── istrings.go ├── applicationdef_posix.go ├── finalizerOn.go ├── popupmenudef.go ├── printerdef.go ├── framedef.go ├── init_posix.go ├── registrydef.go ├── icondef.go ├── bitmapdef.go ├── gifimagedef.go ├── picturedef.go ├── pngimagedef.go ├── jpegimagedef.go ├── callbackthreadsync.go ├── bitmap │ ├── pix_darwin.go │ ├── pix_linux.go │ └── pix_windows.go ├── applicationdef_windows.go ├── callbackmessage.go ├── istream.go ├── callback_windows.go ├── igraphic.go ├── icomponent.go ├── menuitemdef.go ├── iobject.go ├── init_windows.go ├── callbackcreateparams.go ├── platform_windows.go ├── memorystreamdef.go ├── internalfuncs.go ├── formdef.go ├── platform_linux.go ├── stringsdef.go ├── stringlistdef.go ├── imagelistdef.go ├── formres.go ├── iwincontrol.go ├── clipboarddef.go ├── canvasdef.go ├── init.go ├── platform_darwin.go ├── callback_posix.go ├── miniwebviewdef.go ├── cefbrowser.go ├── icontrol.go ├── synbatsyn.go ├── synvbsyn.go ├── syngutter.go ├── syntexsyn.go ├── applicationdef.go ├── syncsssyn.go └── synphpsyn.go ├── pkgs └── libname │ └── lib.go ├── go.mod ├── chart └── dumper.go ├── go.sum └── test └── lcl_test.go /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .vscode/ 3 | .idea/ 4 | *.dll 5 | *.so 6 | *.dylib 7 | 8 | -------------------------------------------------------------------------------- /dylib/floatpatch/floatResultPatch.go: -------------------------------------------------------------------------------- 1 | //go:build !arm 2 | 3 | package floatpatch 4 | 5 | func Getfloat32() float32 6 | 7 | func Getfloat64() float64 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ### GoLCL 2 | 3 | 跨平台,跨架构的 Golang 可视化组件库 4 | 5 | 需要 ```Go 1.18``` 及以上编译 6 | 7 | 关联项目: 8 | 9 | [golcl-liblcl] https://github.com/rarnu/golcl-liblcl 10 | 11 | [golcl-tools] https://github.com/rarnu/golcl-tools 12 | -------------------------------------------------------------------------------- /lcl/stream.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | package lcl 10 | -------------------------------------------------------------------------------- /lcl/api/bitmapdef.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | package api 10 | -------------------------------------------------------------------------------- /lcl/rtl/rtl_posix.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | //go:build !windows 10 | 11 | package rtl 12 | -------------------------------------------------------------------------------- /lcl/win/oleaut32dll.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | //go:build windows 10 | 11 | package win 12 | -------------------------------------------------------------------------------- /pkgs/libname/lib.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | package libname 10 | 11 | var ( 12 | LibName string 13 | ) 14 | -------------------------------------------------------------------------------- /dylib/floatpatch/floatResultPatch_amd64.s: -------------------------------------------------------------------------------- 1 | #include "textflag.h" 2 | 3 | // float32 Getfloat32(); 4 | TEXT ·Getfloat32(SB),NOSPLIT|NOFRAME,$0 5 | MOVL X0, ret(FP) 6 | RET 7 | 8 | // float64 Getfloat64(); 9 | TEXT ·Getfloat64(SB),NOSPLIT|NOFRAME,$0 10 | MOVQ X0, ret(FP) 11 | RET 12 | -------------------------------------------------------------------------------- /lcl/rtl/consts_windows.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | package rtl 10 | 11 | const ( 12 | PathSeparator = "\\" 13 | ) 14 | -------------------------------------------------------------------------------- /lcl/rtl/consts_posix.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | //go:build !windows 10 | 11 | package rtl 12 | 13 | const ( 14 | PathSeparator = "/" 15 | ) 16 | -------------------------------------------------------------------------------- /lcl/api/finalizerOff.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | //go:build !finalizerOn 10 | 11 | package api 12 | 13 | func callGC() { 14 | // no code 15 | } 16 | -------------------------------------------------------------------------------- /lcl/finalizerOff.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | //go:build !finalizerOn 10 | 11 | package lcl 12 | 13 | func setFinalizer(_ any, _ any) { 14 | // no code 15 | } 16 | -------------------------------------------------------------------------------- /lcl/vars.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | package lcl 10 | 11 | import "unsafe" 12 | 13 | var ( 14 | // nullptr 15 | nullptr = unsafe.Pointer(uintptr(0)) 16 | ) 17 | -------------------------------------------------------------------------------- /lcl/api/mousedef.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | package api 10 | 11 | func Mouse_Instance() uintptr { 12 | ret, _, _ := mouse_Instance.Call() 13 | return ret 14 | } 15 | -------------------------------------------------------------------------------- /lcl/api/finalizerOn.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | //go:build finalizerOn 9 | 10 | package api 11 | 12 | import "runtime" 13 | 14 | func callGC() { 15 | runtime.GC() 16 | } 17 | -------------------------------------------------------------------------------- /lcl/api/screendef.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | package api 10 | 11 | func Screen_Instance() uintptr { 12 | ret, _, _ := screen_Instance.Call() 13 | return ret 14 | } 15 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/rarnu/golcl 2 | 3 | go 1.18 4 | 5 | require github.com/vdobler/chart v1.0.0 6 | 7 | require ( 8 | github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect 9 | github.com/llgcode/draw2d v0.0.0-20180825133448-f52c8a71aff0 // indirect 10 | golang.org/x/image v0.0.0-20181030002151-69cc3646b96e // indirect 11 | ) 12 | -------------------------------------------------------------------------------- /lcl/customtypes.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | // 定义一些自有的VCL/LCL类型 9 | 10 | package lcl 11 | 12 | // TIs Is操作符 13 | type TIs uintptr 14 | 15 | // TAs As操作符 16 | type TAs uintptr 17 | -------------------------------------------------------------------------------- /lcl/api/dylib_nontempdll.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | //go:build !tempdll 10 | 11 | package api 12 | 13 | func checkAndReleaseDLL() (bool, string) { 14 | return false, "" 15 | } 16 | -------------------------------------------------------------------------------- /lcl/types/other.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | package types 10 | 11 | var ( 12 | // AppleLogoChar Unicode Apple logo char 13 | AppleLogoChar = string([]byte{0xEF, 0xA3, 0xBF}) 14 | ) 15 | -------------------------------------------------------------------------------- /lcl/debug.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | package lcl 10 | 11 | var ( 12 | // 如果DEBUG=true则不会屏蔽recover()。 13 | 14 | // If DEBUG=true, recover() will not be blocked. 15 | DEBUG = false 16 | ) 17 | -------------------------------------------------------------------------------- /lcl/rtl/init_windows.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | package rtl 10 | 11 | import "github.com/rarnu/golcl/lcl/api" 12 | 13 | // 初始化 14 | func init() { 15 | // 初始 16 | api.DSysLocale(&SysLocale) 17 | } 18 | -------------------------------------------------------------------------------- /lcl/istrings.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | package lcl 10 | 11 | type IStrings interface { 12 | IObject 13 | // 先只简单实现几个吧 14 | Count() int32 15 | S(int32) string 16 | Objects(int32) *TObject 17 | } 18 | -------------------------------------------------------------------------------- /lcl/applicationdef_posix.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | //go:build !windows 10 | 11 | package lcl 12 | 13 | func (a *TApplication) SetIconResId(_ int) { 14 | // 不支持此方法 15 | // This method is not supported 16 | } 17 | -------------------------------------------------------------------------------- /lcl/finalizerOn.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | //go:build finalizerOn 10 | 11 | package lcl 12 | 13 | import "runtime" 14 | 15 | func setFinalizer(obj any, finalizer any) { 16 | runtime.SetFinalizer(obj, finalizer) 17 | 18 | } 19 | -------------------------------------------------------------------------------- /lcl/popupmenudef.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // The code is automatically generated by the GenlibLcl tool. 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | package lcl 10 | 11 | func (p *TPopupMenu) Popup2() { 12 | point := Mouse.CursorPos() 13 | p.Popup(point.X, point.Y) 14 | } 15 | -------------------------------------------------------------------------------- /lcl/printerdef.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | package lcl 10 | 11 | import ( 12 | . "github.com/rarnu/golcl/lcl/api" 13 | ) 14 | 15 | func (p *TPrinter) SetPrinter(aName string) { 16 | Printer_SetPrinter(p.instance, aName) 17 | } 18 | -------------------------------------------------------------------------------- /lcl/framedef.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | package lcl 10 | 11 | // 从资源中创建TFrame。 12 | // 13 | // Create TFrame from resources. 14 | func CreateResFrame(owner IComponent, fields ...any) { 15 | resObjectBuild(2, owner, 0, fields...) 16 | } 17 | -------------------------------------------------------------------------------- /lcl/init_posix.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | //go:build !windows 10 | 11 | package lcl 12 | 13 | import ( 14 | "fmt" 15 | ) 16 | 17 | func showError(err any) { 18 | fmt.Println(err) 19 | } 20 | 21 | func tryLoadAppIcon() { 22 | // no code 23 | } 24 | -------------------------------------------------------------------------------- /lcl/types/message_windows.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | //go:build windows 10 | 11 | package types 12 | 13 | // TMessage 消息值参见 types/messages包 14 | type TMessage struct { 15 | Msg Cardinal 16 | WParam WPARAM 17 | LParam LPARAM 18 | Result LRESULT 19 | } 20 | -------------------------------------------------------------------------------- /lcl/registrydef.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | package lcl 10 | 11 | import ( 12 | "github.com/rarnu/golcl/lcl/win" 13 | ) 14 | 15 | // NewRegistryAllAccess 所有访问权限 16 | func NewRegistryAllAccess() *TRegistry { 17 | return NewRegistry(win.KEY_ALL_ACCESS) 18 | } 19 | -------------------------------------------------------------------------------- /lcl/icondef.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | package lcl 10 | 11 | func (i *TIcon) LoadFromBytes(data []byte) { 12 | if len(data) == 0 { 13 | return 14 | } 15 | mem := NewMemoryStreamFromBytes(data) 16 | defer mem.Free() 17 | mem.SetPosition(0) 18 | i.LoadFromStream(mem) 19 | } 20 | -------------------------------------------------------------------------------- /lcl/bitmapdef.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | package lcl 10 | 11 | func (b *TBitmap) LoadFromBytes(data []byte) { 12 | if len(data) == 0 { 13 | return 14 | } 15 | mem := NewMemoryStreamFromBytes(data) 16 | defer mem.Free() 17 | mem.SetPosition(0) 18 | b.LoadFromStream(mem) 19 | } 20 | -------------------------------------------------------------------------------- /lcl/gifimagedef.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | package lcl 10 | 11 | func (g *TGIFImage) LoadFromBytes(data []byte) { 12 | if len(data) == 0 { 13 | return 14 | } 15 | mem := NewMemoryStreamFromBytes(data) 16 | defer mem.Free() 17 | mem.SetPosition(0) 18 | g.LoadFromStream(mem) 19 | } 20 | -------------------------------------------------------------------------------- /lcl/picturedef.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | package lcl 10 | 11 | func (p *TPicture) LoadFromBytes(data []byte) { 12 | if len(data) == 0 { 13 | return 14 | } 15 | mem := NewMemoryStreamFromBytes(data) 16 | defer mem.Free() 17 | mem.SetPosition(0) 18 | p.LoadFromStream(mem) 19 | } 20 | -------------------------------------------------------------------------------- /lcl/pngimagedef.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | package lcl 10 | 11 | func (p *TPngImage) LoadFromBytes(data []byte) { 12 | if len(data) == 0 { 13 | return 14 | } 15 | mem := NewMemoryStreamFromBytes(data) 16 | defer mem.Free() 17 | mem.SetPosition(0) 18 | p.LoadFromStream(mem) 19 | } 20 | -------------------------------------------------------------------------------- /lcl/jpegimagedef.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | package lcl 10 | 11 | func (j *TJPEGImage) LoadFromBytes(data []byte) { 12 | if len(data) == 0 { 13 | return 14 | } 15 | mem := NewMemoryStreamFromBytes(data) 16 | defer mem.Free() 17 | mem.SetPosition(0) 18 | j.LoadFromStream(mem) 19 | } 20 | -------------------------------------------------------------------------------- /lcl/callbackthreadsync.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | package lcl 10 | 11 | import ( 12 | "github.com/rarnu/golcl/lcl/api" 13 | ) 14 | 15 | // 线程同步的,独立出来 16 | func threadSyncCallbackProc() uintptr { 17 | fn := api.ThreadSyncCallbackFn() 18 | if fn != nil { 19 | fn() 20 | } 21 | return 0 22 | } 23 | -------------------------------------------------------------------------------- /lcl/types/message_posix.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | //go:build !windows 10 | 11 | package types 12 | 13 | // TMessage 消息值参见 types/messages包 14 | type TMessage struct { 15 | Msg Cardinal 16 | _UnusedMsg Cardinal 17 | WParam WPARAM 18 | LParam LPARAM 19 | Result LRESULT 20 | } 21 | -------------------------------------------------------------------------------- /lcl/bitmap/pix_darwin.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | package bitmap 10 | 11 | //var ( 12 | // // A R G B 13 | // // Big Endian 14 | // pixIndex = [4]int{3, 0, 1, 2} 15 | //) 16 | 17 | // Big Endian 18 | type rgba struct { 19 | A, R, G, B uint8 20 | } 21 | 22 | type rgb struct { 23 | R, G, B uint8 24 | } 25 | -------------------------------------------------------------------------------- /lcl/bitmap/pix_linux.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | package bitmap 10 | 11 | //var ( 12 | // // R G B A 13 | // // Little Endian 14 | // pixIndex = [4]int{0, 1, 2, 3} 15 | //) 16 | 17 | // Little Endian 18 | type rgba struct { 19 | R, G, B, A uint8 20 | } 21 | 22 | type rgb struct { 23 | R, G, B uint8 24 | } 25 | -------------------------------------------------------------------------------- /lcl/bitmap/pix_windows.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | package bitmap 10 | 11 | //var ( 12 | // // B G R A 13 | // // Little Endian 14 | // pixIndex = [4]int{2, 1, 0, 3} 15 | //) 16 | 17 | // Little Endian 18 | type rgba struct { 19 | B, G, R, A uint8 20 | } 21 | 22 | type rgb struct { 23 | B, G, R uint8 24 | } 25 | -------------------------------------------------------------------------------- /lcl/api/printerdef.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | package api 10 | 11 | // Printer_Instance Printer 12 | func Printer_Instance() uintptr { 13 | r, _, _ := printer_Instance.Call() 14 | return r 15 | } 16 | 17 | func Printer_SetPrinter(obj uintptr, aName string) { 18 | _, _, _ = printer_SetPrinter.Call(obj, GoStrToDStr(aName)) 19 | } 20 | -------------------------------------------------------------------------------- /lcl/types/window_darwin.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | package types 10 | 11 | type NSWindowTitleVisibility uint 12 | 13 | const ( 14 | NSWindowTitleVisible NSWindowTitleVisibility = iota + 0 15 | NSWindowTitleHidden 16 | ) 17 | 18 | const ( 19 | // NSWindowStyleMaskFullSizeContentView 先只提供一个吧 20 | NSWindowStyleMaskFullSizeContentView = 1 << 15 21 | ) 22 | -------------------------------------------------------------------------------- /lcl/api/importdef_linux.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | //go:build linux 9 | 10 | package api 11 | 12 | var ( 13 | GdkWindow_GetXId = liblcl.NewProc("GdkWindow_GetXId") 14 | GdkWindow_FromForm = liblcl.NewProc("GdkWindow_FromForm") 15 | GtkWidget_GetGtkFixed = liblcl.NewProc("GtkWidget_GetGtkFixed") 16 | GtkWidget_Window = liblcl.NewProc("GtkWidget_Window") 17 | ) 18 | -------------------------------------------------------------------------------- /lcl/applicationdef_windows.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | package lcl 10 | 11 | import ( 12 | "github.com/rarnu/golcl/lcl/win" 13 | ) 14 | 15 | // 从资源中设置图标的id 16 | // 17 | // Sets the id of the icon from the resource. 18 | func (a *TApplication) SetIconResId(id int) { 19 | hicon := win.LoadIcon(win.GetSelfModuleHandle(), id) 20 | if hicon != 0 { 21 | a.Icon().SetHandle(hicon) 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /lcl/callbackmessage.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | package lcl 10 | 11 | import ( 12 | "unsafe" 13 | 14 | . "github.com/rarnu/golcl/lcl/api" 15 | . "github.com/rarnu/golcl/lcl/types" 16 | ) 17 | 18 | func messageCallbackProc(f uintptr, msg uintptr) uintptr { 19 | if v, ok := MessageCallbackOf(f); ok { 20 | v.(TWndProcEvent)( 21 | (*TMessage)(unsafe.Pointer(msg)), 22 | ) 23 | } 24 | return 0 25 | } 26 | -------------------------------------------------------------------------------- /lcl/rtl/version/init.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | package version 10 | 11 | import "runtime" 12 | 13 | func init() { 14 | switch runtime.GOARCH { 15 | case "386": 16 | OSVersion.Architecture = ArIntelX86 17 | case "amd64": 18 | OSVersion.Architecture = ArIntelX64 19 | case "arm": 20 | OSVersion.Architecture = ArARM32 21 | case "arm64": 22 | OSVersion.Architecture = ArARM64 23 | default: 24 | } 25 | initOSVersion() 26 | } 27 | -------------------------------------------------------------------------------- /lcl/istream.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | package lcl 10 | 11 | import ( 12 | . "github.com/rarnu/golcl/lcl/types" 13 | ) 14 | 15 | type IStream interface { 16 | IObject 17 | Size() int64 18 | SetSize(value int64) 19 | Position() int64 20 | SetPosition(int64) 21 | Read(count int32) (int32, []byte) 22 | Write(buffer []byte) int32 23 | Seek(Offset int64, Origin TSeekOrigin) int64 24 | CopyFrom(Source IStream, Count int64) int64 25 | } 26 | -------------------------------------------------------------------------------- /lcl/api/formdef.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | package api 10 | 11 | func Form_Create2(owner uintptr, initScale bool) uintptr { 12 | ret, _, _ := form_Create2.Call(owner, GoBoolToDBool(initScale)) 13 | return ret 14 | } 15 | 16 | func Form_SetOnWndProc(obj uintptr, fn any) { 17 | _, _, _ = form_SetOnWndProc.Call(obj, addMessageEventToMap(obj, fn)) 18 | } 19 | 20 | func Form_SetGoPtr(obj uintptr, ptr uintptr) { 21 | _, _, _ = form_SetGoPtr.Call(obj, ptr) 22 | } 23 | -------------------------------------------------------------------------------- /lcl/callback_windows.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | package lcl 10 | 11 | import ( 12 | "syscall" 13 | ) 14 | 15 | var ( 16 | eventCallback = syscall.NewCallback(eventCallbackProc) 17 | messageCallback = syscall.NewCallback(messageCallbackProc) 18 | threadSyncCallback = syscall.NewCallback(threadSyncCallbackProc) 19 | requestCallCreateParamsCallback = syscall.NewCallback(requestCallCreateParamsCallbackProc) 20 | ) 21 | -------------------------------------------------------------------------------- /lcl/igraphic.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | package lcl 10 | 11 | type IGraphic interface { 12 | IObject 13 | LoadFromFile(string) 14 | SaveToFile(string) 15 | LoadFromStream(IStream) 16 | SaveToStream(IStream) 17 | Assign(IObject) 18 | Empty() bool 19 | Height() int32 20 | SetHeight(value int32) 21 | Modified() bool 22 | SetModified(value bool) 23 | Transparent() bool 24 | SetTransparent(value bool) 25 | Width() int32 26 | SetWidth(value int32) 27 | } 28 | -------------------------------------------------------------------------------- /lcl/icomponent.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | package lcl 10 | 11 | type IComponent interface { 12 | IObject 13 | 14 | FindComponent(string) *TComponent 15 | GetNamePath() string 16 | HasParent() bool 17 | Assign(IObject) 18 | 19 | ComponentCount() int32 20 | ComponentIndex() int32 21 | SetComponentIndex(int32) 22 | Components(int32) *TComponent 23 | 24 | Owner() *TComponent 25 | 26 | Name() string 27 | SetName(string) 28 | 29 | Tag() int 30 | SetTag(int) 31 | } 32 | -------------------------------------------------------------------------------- /lcl/menuitemdef.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | package lcl 10 | 11 | import ( 12 | . "github.com/rarnu/golcl/lcl/api" 13 | ) 14 | 15 | // 设置快捷键字符 16 | // 17 | // Set shortcut key characters. 18 | func (m *TMenuItem) SetShortCutFromString(s string) { 19 | MenuItem_SetShortCut(m.instance, DTextToShortCut(s)) 20 | } 21 | 22 | // 获取快捷键字符 23 | // 24 | // Get shortcut key characters. 25 | func (m *TMenuItem) ShortCutFromString() string { 26 | return DShortCutToText(MenuItem_GetShortCut(m.instance)) 27 | } 28 | -------------------------------------------------------------------------------- /lcl/rtl/guid.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | package rtl 10 | 11 | import ( 12 | "github.com/rarnu/golcl/lcl/api" 13 | "github.com/rarnu/golcl/lcl/types" 14 | ) 15 | 16 | // GUIDToString 将TGUID转为字符形式 17 | func GUIDToString(guid types.TGUID) string { 18 | return guid.ToString() 19 | } 20 | 21 | // StringToGUID 将字符形式的GUID转为TGUID结构 22 | func StringToGUID(str string) types.TGUID { 23 | return api.DStringToGUID(str) 24 | } 25 | 26 | // CreateGUID 创建一个新的GUID 27 | func CreateGUID() types.TGUID { 28 | return api.DCreateGUID() 29 | } 30 | -------------------------------------------------------------------------------- /lcl/rtl/rtl_windows.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | package rtl 10 | 11 | import "github.com/rarnu/golcl/lcl/api" 12 | 13 | // Shortcut 14 | 15 | // 创建一个url的快捷方式 16 | func CreateURLShortCut(aDestPath, aShortCutName, aURL string) { 17 | api.DCreateURLShortCut(aDestPath, aShortCutName, aURL) 18 | } 19 | 20 | // 创建一个快捷方式 21 | func CreateShortCut(aDestPath, aShortCutName, aSrcFileName, aIconFileName, aDescription, aCmdArgs string) bool { 22 | return api.DCreateShortCut(aDestPath, aShortCutName, aSrcFileName, aIconFileName, aDescription, aCmdArgs) 23 | } 24 | -------------------------------------------------------------------------------- /lcl/iobject.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | package lcl 10 | 11 | import ( 12 | "unsafe" 13 | 14 | "github.com/rarnu/golcl/lcl/types" 15 | ) 16 | 17 | // IObject 共公的对象接口 18 | type IObject interface { 19 | Instance() uintptr 20 | IsValid() bool 21 | UnsafeAddr() unsafe.Pointer 22 | 23 | ClassName() string 24 | Free() 25 | GetHashCode() int32 26 | Equals(IObject) bool 27 | // ClassType DisposeOf() 28 | ClassType() types.TClass 29 | InstanceSize() int32 30 | InheritsFrom(types.TClass) bool 31 | 32 | Is() TIs 33 | As() TAs 34 | 35 | ToString() string 36 | } 37 | -------------------------------------------------------------------------------- /lcl/init_windows.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | package lcl 10 | 11 | import ( 12 | "fmt" 13 | 14 | . "github.com/rarnu/golcl/lcl/win" 15 | ) 16 | 17 | func showError(err any) { 18 | MessageBox(0, fmt.Sprint(err), "Error", MB_ICONERROR) 19 | } 20 | 21 | // 尝试加载默认Application icon 22 | // 23 | // Try to load the default Application icon. 24 | func tryLoadAppIcon() { 25 | // 将来会删除此代码,因为liblcl中已经做了处理了 26 | if Application.Icon().Handle() == 0 { 27 | hIcon := LoadIcon2(GetSelfModuleHandle(), "MAINICON") 28 | if hIcon != 0 { 29 | Application.Icon().SetHandle(hIcon) 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /lcl/api/memorystreamdef.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | package api 10 | 11 | import ( 12 | "unsafe" 13 | ) 14 | 15 | // MemoryStream_Read 还需要待测试 16 | func MemoryStream_Read(obj uintptr, count int32) (int32, []byte) { 17 | if count <= 0 { 18 | return 0, nil 19 | } 20 | bs := make([]byte, count) 21 | r, _, _ := memoryStream_Read.Call(obj, uintptr(unsafe.Pointer(&bs[0])), uintptr(count)) 22 | return int32(r), bs 23 | } 24 | 25 | func MemoryStream_Write(obj uintptr, buffer []byte) int32 { 26 | r, _, _ := memoryStream_Write.Call(obj, uintptr(unsafe.Pointer(&buffer[0])), uintptr(len(buffer))) 27 | return int32(r) 28 | } 29 | -------------------------------------------------------------------------------- /lcl/rtl/init_posix.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | //go:build !windows 10 | 11 | package rtl 12 | 13 | import ( 14 | "os" 15 | "strings" 16 | ) 17 | 18 | // 初始化 19 | func init() { 20 | SysLocale.FarEast = true 21 | SysLocale.MiddleEast = true 22 | // 这个环境变量在MacOS下只有通过命令行启动的才能获取得到。 23 | // Linux下不知道有哪些不能获取到的。 24 | lang := os.Getenv("LANG") 25 | if lang != "" { 26 | lang = strings.Replace(lang, "_", "-", -1) 27 | if strings.Contains(lang, ".") { 28 | SysLocale.DefaultLCID = LocaleIDFromName(lang[:strings.Index(lang, ".")]) 29 | } else { 30 | SysLocale.DefaultLCID = LocaleIDFromName(lang) 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /lcl/callbackcreateparams.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | package lcl 10 | 11 | import ( 12 | "reflect" 13 | "sync" 14 | "unsafe" 15 | 16 | "github.com/rarnu/golcl/lcl/types" 17 | ) 18 | 19 | var requestCreateParamsMap sync.Map 20 | 21 | func addToRequestCreateParamsMap(ptr uintptr, proc reflect.Value) { 22 | requestCreateParamsMap.Store(ptr, proc) 23 | } 24 | 25 | func requestCallCreateParamsCallbackProc(ptr uintptr, params uintptr) uintptr { 26 | if val, ok := requestCreateParamsMap.Load(ptr); ok { 27 | val.(reflect.Value).Call([]reflect.Value{reflect.ValueOf((*types.TCreateParams)(unsafe.Pointer(params)))}) 28 | } 29 | return 0 30 | } 31 | -------------------------------------------------------------------------------- /lcl/win/psapidll.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | //go:build windows 10 | 11 | package win 12 | 13 | import ( 14 | "unsafe" 15 | 16 | . "github.com/rarnu/golcl/lcl/types" 17 | ) 18 | 19 | import "syscall" 20 | 21 | var ( 22 | psapidll = syscall.NewLazyDLL("psapi.dll") 23 | 24 | _GetModuleFileNameEx = psapidll.NewProc("GetModuleFileNameExW") 25 | ) 26 | 27 | func GetModuleFileNameEx(hProcess uintptr, hModule HMODULE) (string, uint32) { 28 | buff := make([]uint16, MAX_PATH) 29 | r, _, _ := _GetModuleFileNameEx.Call(hProcess, uintptr(hModule), uintptr(unsafe.Pointer(&buff[0])), uintptr(MAX_PATH*2)) 30 | return GoStr(buff), uint32(r) 31 | } 32 | -------------------------------------------------------------------------------- /lcl/platform_windows.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | //go:build windows 10 | 11 | package lcl 12 | 13 | import . "github.com/rarnu/golcl/lcl/types" 14 | 15 | type Window HWND 16 | 17 | // Handle 18 | func HandleToPlatformHandle(h HWND) Window { 19 | 20 | return Window(h) 21 | } 22 | 23 | func (f *TForm) PlatformWindow() Window { 24 | return Window(f.Handle()) 25 | } 26 | 27 | //func (w Window) SendMessage(msg uint32, wParam, lParam uintptr) uintptr { 28 | // return win.SendMessage(HWND(w), msg, wParam, lParam) 29 | //} 30 | // 31 | //func (w Window) PostMessage(msg uint32, wParam, lParam uintptr) uintptr { 32 | // return win.PostMessage(HWND(w), msg, wParam, lParam) 33 | //} 34 | -------------------------------------------------------------------------------- /lcl/memorystreamdef.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | package lcl 10 | 11 | import ( 12 | . "github.com/rarnu/golcl/lcl/api" 13 | ) 14 | 15 | // 新建Delphi/Lazarus内存流来自Go字节数组。 16 | // 17 | // New Delphi/Lazarus memory stream from Go byte array. 18 | func NewMemoryStreamFromBytes(data []byte) *TMemoryStream { 19 | m := NewMemoryStream() 20 | m.Write(data) 21 | return m 22 | } 23 | 24 | // 读数据 25 | // 26 | // Read Data. 27 | func (m *TMemoryStream) Read(count int32) (int32, []byte) { 28 | return MemoryStream_Read(m.instance, count) 29 | } 30 | 31 | // 写数据 32 | // 33 | // Write Data. 34 | func (m *TMemoryStream) Write(buffer []byte) int32 { 35 | return MemoryStream_Write(m.instance, buffer) 36 | } 37 | -------------------------------------------------------------------------------- /lcl/api/applicationdef.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | package api 10 | 11 | func Application_Instance() uintptr { 12 | ret, _, _ := application_Instance.Call() 13 | return ret 14 | } 15 | 16 | func Application_CreateForm(app uintptr, initScale bool) uintptr { 17 | ret, _, _ := application_CreateForm.Call(app, GoBoolToDBool(initScale)) 18 | return ret 19 | } 20 | 21 | func Application_Run(app uintptr) { 22 | defer func() { 23 | // 开启了finalizerOn选项后,以防止关闭库后GC还没开始调用。 24 | callGC() 25 | // 运行结束后就结束close掉lib,不然他不会关掉的 26 | closeLib() 27 | }() 28 | _, _, _ = application_Run.Call(app) 29 | } 30 | 31 | func Application_Initialize(obj uintptr) { 32 | _, _, _ = application_Initialize.Call(obj) 33 | } 34 | -------------------------------------------------------------------------------- /lcl/api/importFuncsChartStyleEnumerator.go: -------------------------------------------------------------------------------- 1 | package api 2 | 3 | import ( 4 | . "github.com/rarnu/golcl/lcl/types" 5 | ) 6 | 7 | func ChartStyleEnumerator_Create(obj uintptr) uintptr { 8 | ret, _, _ := getLazyProc("ChartStyleEnumerator_Create").Call(obj) 9 | return ret 10 | } 11 | 12 | func ChartStyleEnumerator_Free(obj uintptr) { 13 | _, _, _ = getLazyProc("ChartStyleEnumerator_Free").Call(obj) 14 | } 15 | 16 | func ChartStyleEnumerator_StaticClassType() TClass { 17 | ret, _, _ := getLazyProc("ChartStyleEnumerator_StaticClassType").Call() 18 | return TClass(ret) 19 | } 20 | 21 | func ChartStyleEnumerator_GetCurrent(obj uintptr) uintptr { 22 | ret, _, _ := getLazyProc("ChartStyleEnumerator_GetCurrent").Call(obj) 23 | return ret 24 | } 25 | 26 | func ChartStyleEnumerator_MoveNext(obj uintptr) bool { 27 | ret, _, _ := getLazyProc("ChartStyleEnumerator_MoveNext").Call(obj) 28 | return DBoolToGoBool(ret) 29 | } 30 | -------------------------------------------------------------------------------- /lcl/api/importFuncsChartTextOut.go: -------------------------------------------------------------------------------- 1 | package api 2 | 3 | /* 4 | TChartTextOut = class 5 | strict private 6 | FAlignment: TAlignment; 7 | FPos: TPoint; 8 | FSimpleTextOut: ISimpleTextOut; 9 | FText1: String; 10 | FText2: TStrings; 11 | FTextFormat: TChartTextFormat; 12 | FWidth: Integer; 13 | 14 | procedure DoTextOutList; 15 | procedure DoTextOutString; 16 | public 17 | constructor Create(ASimpleTextOut: ISimpleTextOut); 18 | public 19 | function Alignment(AAlignment: TAlignment): TChartTextOut; 20 | procedure Done; 21 | function Pos(AX, AY: Integer): TChartTextOut; 22 | function Pos(const APos: TPoint): TChartTextOut; 23 | function Text(const AText: String): TChartTextOut; 24 | function Text(AText: TStrings): TChartTextOut; 25 | function TextFormat(AFormat: TChartTextFormat): TChartTextOut; 26 | function Width(AWidth: Integer): TChartTextOut; 27 | end; 28 | */ 29 | -------------------------------------------------------------------------------- /lcl/rtl/intf.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | package rtl 10 | 11 | import . "github.com/rarnu/golcl/lcl/types" 12 | 13 | func MakeWord(A, B uint8) uint16 { 14 | return uint16(A | B<<8) 15 | } 16 | 17 | func MakeLong(A, B uint16) int32 { 18 | return int32(A | B<<16) 19 | } 20 | 21 | func HiWord(L uint32) uint16 { 22 | return uint16(L >> 16) 23 | } 24 | 25 | func HiByte(W uint8) uint8 { 26 | return W >> 8 27 | } 28 | 29 | func MakeWParam(l, h uint16) WPARAM { 30 | return WPARAM(MakeLong(l, h)) 31 | } 32 | 33 | func MakeLParam(l, h uint16) LPARAM { 34 | return LPARAM(MakeLong(l, h)) 35 | } 36 | 37 | func MakeLResult(l, h uint16) LRESULT { 38 | return LRESULT(MakeLong(l, h)) 39 | } 40 | 41 | func PointToLParam(P TPoint) LPARAM { 42 | return LPARAM((P.X & 0x0000FFFF) | (P.Y << 16)) 43 | } 44 | -------------------------------------------------------------------------------- /lcl/internalfuncs.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | package lcl 10 | 11 | // 获取控件buffer文本,内部使用的 12 | //go:noinline 13 | func getControlBufferText(aGetTextLen func() int32, aGetTextBuf func(Buffer *string, BufSize int32) int32) string { 14 | strLen := aGetTextLen() 15 | if strLen != 0 { 16 | var buffStr string 17 | aGetTextBuf(&buffStr, strLen+1) 18 | return buffStr 19 | } 20 | return "" 21 | } 22 | 23 | // 内部的从流获取 24 | func getStreamText(stream IStream) string { 25 | if stream != nil && stream.IsValid() { 26 | size := stream.Size() 27 | stream.SetPosition(0) 28 | if size > 0 { 29 | n, buff := stream.Read(int32(size)) 30 | if n > 0 && buff[len(buff)-1] == 0 { 31 | return string(buff[:len(buff)-1]) 32 | } else { 33 | return string(buff) 34 | } 35 | } 36 | } 37 | return "" 38 | } 39 | -------------------------------------------------------------------------------- /lcl/formdef.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | package lcl 10 | 11 | import . "github.com/rarnu/golcl/lcl/api" 12 | 13 | // 从资源中创建Form,不使用Application.CreateForm 14 | func CreateResForm(owner IComponent, fields ...any) { 15 | resObjectBuild(1, owner, 0, fields...) 16 | } 17 | 18 | // 窗口消息过程 19 | func (f *TForm) SetOnWndProc(fn TWndProcEvent) { 20 | Form_SetOnWndProc(f.instance, fn) 21 | } 22 | 23 | func (f *TForm) setGoPtr(ptr uintptr) { 24 | Form_SetGoPtr(f.instance, ptr) 25 | } 26 | 27 | // 这个方法主要是用于当不使用资源窗口创建时用,这个方法要用于设置了Width, Height或者ClientWidth、ClientHeight之后 28 | func (f *TForm) ScaleSelf() { 29 | if Application.Scaled() { 30 | f.SetClientWidth(int32(float64(f.ClientWidth()) * (float64(Screen.PixelsPerInch()) / 96.0))) 31 | f.SetClientHeight(int32(float64(f.ClientHeight()) * (float64(Screen.PixelsPerInch()) / 96.0))) 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /lcl/win/ole32dll.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | //go:build windows 10 | 11 | package win 12 | 13 | import ( 14 | . "github.com/rarnu/golcl/lcl/types" 15 | ) 16 | 17 | import "syscall" 18 | 19 | const ( 20 | ole32 = "ole32.dll" 21 | ) 22 | 23 | var ( 24 | ole32dll = syscall.NewLazyDLL(ole32) 25 | 26 | _CoInitialize = ole32dll.NewProc("CoInitialize") 27 | _CoInitializeEx = ole32dll.NewProc("CoInitializeEx") 28 | _CoUninitialize = ole32dll.NewProc("CoUninitialize") 29 | ) 30 | 31 | func CoInitialize(pvReserved uintptr) HResult { 32 | r, _, _ := _CoInitialize.Call(pvReserved) 33 | return HResult(r) 34 | } 35 | 36 | func CoInitializeEx(pvReserved uintptr, coInit uint32) HResult { 37 | r, _, _ := _CoInitializeEx.Call(pvReserved, uintptr(coInit)) 38 | return HResult(r) 39 | } 40 | 41 | func CoUninitialize() { 42 | _CoUninitialize.Call() 43 | } 44 | -------------------------------------------------------------------------------- /lcl/api/applicationformresdef.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | //---------------------------------------- 10 | // 加载文件或者内存中的窗口资源文件功能 11 | // 需要配合窗口设计器使用 12 | //---------------------------------------- 13 | 14 | package api 15 | 16 | var ( 17 | resFormLoadFromStream = liblcl.NewProc("ResFormLoadFromStream") 18 | resFormLoadFromFile = liblcl.NewProc("ResFormLoadFromFile") 19 | resFormLoadFromResourceName = liblcl.NewProc("ResFormLoadFromResourceName") 20 | ) 21 | 22 | func ResFormLoadFromStream(obj, root uintptr) { 23 | _, _, _ = resFormLoadFromStream.Call(obj, root) 24 | } 25 | 26 | func ResFormLoadFromFile(filename string, root uintptr) { 27 | _, _, _ = resFormLoadFromFile.Call(GoStrToDStr(filename), root) 28 | } 29 | 30 | func ResFormLoadFromResourceName(instance uintptr, resName string, root uintptr) { 31 | _, _, _ = resFormLoadFromResourceName.Call(instance, GoStrToDStr(resName), root) 32 | } 33 | -------------------------------------------------------------------------------- /lcl/api/importdef_darwin.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | //go:build darwin 10 | 11 | package api 12 | 13 | var ( 14 | NSWindow_FromForm = liblcl.NewProc("NSWindow_FromForm") 15 | NSWindow_titleVisibility = liblcl.NewProc("NSWindow_titleVisibility") 16 | NSWindow_setTitleVisibility = liblcl.NewProc("NSWindow_setTitleVisibility") 17 | NSWindow_titlebarAppearsTransparent = liblcl.NewProc("NSWindow_titlebarAppearsTransparent") 18 | NSWindow_setTitlebarAppearsTransparent = liblcl.NewProc("NSWindow_setTitlebarAppearsTransparent") 19 | NSWindow_styleMask = liblcl.NewProc("NSWindow_styleMask") 20 | NSWindow_setStyleMask = liblcl.NewProc("NSWindow_setStyleMask") 21 | NSWindow_setRepresentedURL = liblcl.NewProc("NSWindow_setRepresentedURL") 22 | //NSWindow_release = libvcl.NewProc("NSWindow_release") 23 | ) 24 | -------------------------------------------------------------------------------- /lcl/win/enums.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | //go:build windows 10 | 11 | package win 12 | 13 | type TTokenType uint32 14 | 15 | const ( 16 | TokenTPad TTokenType = iota + 0 17 | TokenPrimary 18 | TokenImpersonation 19 | ) 20 | 21 | type TTokenInformationClass uint32 22 | 23 | const ( 24 | TokenUser TTokenInformationClass = iota + 1 25 | TokenGroups 26 | TokenPrivileges 27 | TokenOwner 28 | TokenPrimaryGroup 29 | TokenDefaultDacl 30 | TokenSource 31 | TokenType 32 | TokenImpersonationLevel 33 | TokenStatistics 34 | TokenRestrictedSids 35 | TokenSessionId 36 | TokenGroupsAndPrivileges 37 | TokenSessionReference 38 | TokenSandBoxInert 39 | TokenAuditPolicy 40 | TokenOrigin 41 | TokenElevationType 42 | TokenLinkedToken 43 | TokenElevation 44 | TokenHasRestrictions 45 | TokenAccessInformation 46 | TokenVirtualizationAllowed 47 | TokenVirtualizationEnabled 48 | TokenIntegrityLevel 49 | TokenUIAccess 50 | TokenMandatoryPolicy 51 | TokenLogonSid 52 | VMaxTokenInfoClass 53 | ) 54 | -------------------------------------------------------------------------------- /lcl/platform_linux.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | //go:build linux 10 | 11 | package lcl 12 | 13 | import ( 14 | "github.com/rarnu/golcl/lcl/api" 15 | "github.com/rarnu/golcl/lcl/types" 16 | "unsafe" 17 | ) 18 | 19 | type GdkWindow uintptr 20 | 21 | type GtkWidget uintptr 22 | 23 | type GtkFixed uintptr 24 | 25 | type XID uintptr 26 | 27 | // PGtkWidget 28 | func HandleToPlatformHandle(h types.HWND) GtkWidget { 29 | 30 | return GtkWidget(h) 31 | } 32 | 33 | func (f *TForm) PlatformWindow() GdkWindow { 34 | r, _, _ := api.GdkWindow_FromForm.Call(f.instance) 35 | return GdkWindow(r) 36 | } 37 | 38 | func (g GdkWindow) XID() (xid XID) { 39 | api.GdkWindow_GetXId.Call(uintptr(g), uintptr(unsafe.Pointer(&xid))) 40 | return 41 | } 42 | 43 | // lz中首先是一个widget,然后上面用了一个fixedWidget来处理的。 44 | func (g GtkWidget) FixedWidget() GtkFixed { 45 | r, _, _ := api.GtkWidget_GetGtkFixed.Call(uintptr(g)) 46 | return GtkFixed(r) 47 | } 48 | 49 | func (g GtkWidget) Window() GdkWindow { 50 | return 0 51 | r, _, _ := api.GtkWidget_Window.Call(uintptr(g)) 52 | return GdkWindow(r) 53 | } 54 | -------------------------------------------------------------------------------- /lcl/win/advapi32dll.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | //go:build windows 10 | 11 | package win 12 | 13 | import ( 14 | "syscall" 15 | "unsafe" 16 | ) 17 | 18 | var ( 19 | 20 | // advapi32.dll 21 | advapi32dll = syscall.NewLazyDLL("advapi32.dll") 22 | 23 | _OpenProcessToken = advapi32dll.NewProc("OpenProcessToken") 24 | _GetTokenInformation = advapi32dll.NewProc("GetTokenInformation") 25 | ) 26 | 27 | // OpenProcessToken 28 | func OpenProcessToken(ProcessHandle uintptr, DesiredAccess uint32, TokenHandle *uintptr) bool { 29 | r, _, _ := _OpenProcessToken.Call(ProcessHandle, uintptr(DesiredAccess), uintptr(unsafe.Pointer(TokenHandle))) 30 | return r != 0 31 | } 32 | 33 | // GetTokenInformation 34 | func GetTokenInformation(TokenHandle uintptr, TokenInformationClass TTokenInformationClass, TokenInformation uintptr, TokenInformationLength uint32, 35 | ReturnLength *uint32) bool { 36 | r, _, _ := _GetTokenInformation.Call(TokenHandle, uintptr(TokenInformationClass), TokenInformation, uintptr(TokenInformationLength), uintptr(unsafe.Pointer(ReturnLength))) 37 | return r != 0 38 | } 39 | -------------------------------------------------------------------------------- /lcl/api/dylib_nonmemory.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | package api 10 | 11 | import ( 12 | "github.com/rarnu/golcl/dylib" 13 | "github.com/rarnu/golcl/pkgs/libname" 14 | ) 15 | 16 | // 加载库 17 | func loadUILib() *dylib.LazyDLL { 18 | libName := getDLLName() 19 | // 如果支持运行时释放,则使用此种方法 20 | if support, newDLLPath := checkAndReleaseDLL(); support { 21 | libName = newDLLPath 22 | } else { 23 | if libname.LibName != "" { 24 | libName = libname.LibName 25 | } 26 | } 27 | lib := dylib.NewLazyDLL(libName) 28 | err := lib.Load() 29 | if err != nil { 30 | panic(err) 31 | } 32 | if getLibType(lib) != 1 { 33 | // 当前已经不再支持VCL库了 34 | panic("The VCL library is not supported.") 35 | } 36 | return lib 37 | } 38 | 39 | func getLibType(lib *dylib.LazyDLL) int32 { 40 | proc := lib.NewProc("DGetLibType") 41 | r, _, _ := proc.Call() 42 | return int32(r) 43 | } 44 | 45 | // GetLibVcl 获取dll库实例,用于在外扩展第三方组件的。移动来自dfuncs.go 46 | func GetLibVcl() *dylib.LazyDLL { 47 | return liblcl 48 | } 49 | 50 | func closeLib() { 51 | if liblcl != nil { 52 | liblcl.Close() 53 | liblcl = nil 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /lcl/api/dylib.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | package api 10 | 11 | import ( 12 | "runtime" 13 | "sync" 14 | 15 | "github.com/rarnu/golcl/dylib" 16 | ) 17 | 18 | var ( 19 | 20 | // IsWindows 专用于判断是否为Windows系统 21 | IsWindows = runtime.GOOS == "windows" 22 | 23 | // 全局导入库 24 | liblcl = loadUILib() 25 | 26 | // 导出的DLL,考虑到导入的函数太多了,导致go无法编译通过 27 | // 只能动态作,这样可能牺牲一点性能吧,但文件大小会减小几M左右吧。 28 | functions sync.Map 29 | ) 30 | 31 | var ( 32 | platformExtNames = map[string]string{ 33 | "windows": ".dll", 34 | "linux": ".so", 35 | "darwin": ".dylib", 36 | } 37 | ) 38 | 39 | func getDLLName() string { 40 | libName := "liblcl" 41 | if runtime.GOARCH == "arm64" { 42 | // 对于 aarch64,加个后缀来区分 43 | libName += "a" 44 | } 45 | if ext, ok := platformExtNames[runtime.GOOS]; ok { 46 | return libName + ext 47 | } 48 | return libName 49 | } 50 | 51 | func getLazyProc(name string) *dylib.LazyProc { 52 | if val, ok := functions.Load(name); !ok { 53 | proc := liblcl.NewProc(name) 54 | functions.Store(name, proc) 55 | return proc 56 | } else { 57 | return val.(*dylib.LazyProc) 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /lcl/api/importFuncsChartSeriesList.go: -------------------------------------------------------------------------------- 1 | package api 2 | 3 | import ( 4 | . "github.com/rarnu/golcl/lcl/types" 5 | ) 6 | 7 | func ChartSeriesList_Create(obj uintptr) uintptr { 8 | ret, _, _ := getLazyProc("ChartSeriesList_Create").Call(obj) 9 | return ret 10 | } 11 | 12 | func ChartSeriesList_Free(obj uintptr) { 13 | _, _, _ = getLazyProc("ChartSeriesList_Free").Call(obj) 14 | } 15 | 16 | func ChartSeriesList_StaticClassType() TClass { 17 | ret, _, _ := getLazyProc("ChartSeriesList_StaticClassType").Call() 18 | return TClass(ret) 19 | } 20 | 21 | func ChartSeriesList_Clear(obj uintptr) { 22 | _, _, _ = getLazyProc("ChartSeriesList_Clear").Call(obj) 23 | } 24 | 25 | func ChartSeriesList_Count(obj uintptr) int32 { 26 | ret, _, _ := getLazyProc("ChartSeriesList_Count").Call(obj) 27 | return int32(ret) 28 | } 29 | 30 | func ChartSeriesList_GetEnumerator(obj uintptr) uintptr { 31 | ret, _, _ := getLazyProc("ChartSeriesList_GetEnumerator").Call(obj) 32 | return ret 33 | } 34 | 35 | func ChartSeriesList_UpdateBiDiMode(obj uintptr) { 36 | _, _, _ = getLazyProc("ChartSeriesList_UpdateBiDiMode").Call(obj) 37 | } 38 | 39 | func ChartSeriesList_GetItems(obj uintptr, AIndex int32) uintptr { 40 | ret, _, _ := getLazyProc("ChartSeriesList_GetItems").Call(obj, uintptr(AIndex)) 41 | return ret 42 | } 43 | -------------------------------------------------------------------------------- /lcl/api/importFuncsChartStyles.go: -------------------------------------------------------------------------------- 1 | package api 2 | 3 | import ( 4 | . "github.com/rarnu/golcl/lcl/types" 5 | ) 6 | 7 | func ChartStyles_Create(obj uintptr) uintptr { 8 | ret, _, _ := getLazyProc("ChartStyles_Create").Call(obj) 9 | return ret 10 | } 11 | 12 | func ChartStyles_Free(obj uintptr) { 13 | _, _, _ = getLazyProc("ChartStyles_Free").Call(obj) 14 | } 15 | 16 | func ChartStyles_StaticClassType() TClass { 17 | ret, _, _ := getLazyProc("ChartStyles_StaticClassType").Call() 18 | return TClass(ret) 19 | } 20 | 21 | func ChartStyles_GetStyles(obj uintptr) uintptr { 22 | ret, _, _ := getLazyProc("ChartStyles_GetStyles").Call(obj) 23 | return ret 24 | } 25 | 26 | func ChartStyles_SetStyles(obj uintptr, value uintptr) { 27 | _, _, _ = getLazyProc("ChartStyles_SetStyles").Call(obj, value) 28 | } 29 | 30 | func ChartStyles_Add(obj uintptr) uintptr { 31 | ret, _, _ := getLazyProc("ChartStyles_Add").Call(obj) 32 | return ret 33 | } 34 | 35 | func ChartStyles_Apply(obj uintptr, ADrawer uintptr, AIndex Cardinal, IgnoreBrush bool) { 36 | _, _, _ = getLazyProc("ChartStyles_Apply").Call(obj, ADrawer, uintptr(AIndex), GoBoolToDBool(IgnoreBrush)) 37 | } 38 | 39 | func ChartStyles_StyleByIndex(obj uintptr, AIndex Cardinal) uintptr { 40 | ret, _, _ := getLazyProc("ChartStyles_StyleByIndex").Call(obj, uintptr(AIndex)) 41 | return ret 42 | } 43 | -------------------------------------------------------------------------------- /lcl/win/netapi32dll.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | //go:build windows 10 | 11 | package win 12 | 13 | import ( 14 | "syscall" 15 | "unsafe" 16 | ) 17 | 18 | type WKSTA_INFO_100 struct { 19 | Wki100_platform_id uint32 20 | Wki100_computername uintptr // LPWSTR 21 | Wki100_langroup uintptr // LPWSTR 22 | Wki100_ver_major uint32 23 | Wki100_ver_minor uint32 24 | } 25 | 26 | //LPWKSTA_INFO_100 = ^WKSTA_INFO_100; 27 | 28 | const ( 29 | netapi = "netapi32.dll" 30 | 31 | NERR_Success = 0 32 | ) 33 | 34 | var ( 35 | netapidll = syscall.NewLazyDLL(netapi) 36 | _NetWkstaGetInfo100 = netapidll.NewProc("NetWkstaGetInfo") 37 | _NetApiBufferFree = netapidll.NewProc("NetApiBufferFree") 38 | ) 39 | 40 | func NetWkstaGetInfo100(ServerName string, Level uint32, BufPtr **WKSTA_INFO_100) uint32 { 41 | r, _, _ := _NetWkstaGetInfo100.Call(uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(ServerName))), uintptr(Level), 42 | uintptr(unsafe.Pointer(BufPtr))) 43 | return uint32(r) 44 | } 45 | 46 | func NetApiBufferFree(BufPtr *WKSTA_INFO_100) uint32 { 47 | r, _, _ := _NetApiBufferFree.Call(uintptr(unsafe.Pointer(BufPtr))) 48 | return uint32(r) 49 | } 50 | -------------------------------------------------------------------------------- /lcl/types/cursors.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | package types 10 | 11 | // 光标定义 12 | const ( 13 | CrHigh = TCursor(0) 14 | 15 | CrDefault = TCursor(0) 16 | CrNone = TCursor(-1) 17 | CrArrow = TCursor(-2) 18 | CrCross = TCursor(-3) 19 | CrIBeam = TCursor(-4) 20 | CrSize = TCursor(-22) 21 | CrSizeNESW = TCursor(-6) // diagonal north east - south west 22 | CrSizeNS = TCursor(-7) 23 | CrSizeNWSE = TCursor(-8) 24 | CrSizeWE = TCursor(-9) 25 | CrSizeNW = TCursor(-23) 26 | CrSizeN = TCursor(-24) 27 | CrSizeNE = TCursor(-25) 28 | CrSizeW = TCursor(-26) 29 | CrSizeE = TCursor(-27) 30 | CrSizeSW = TCursor(-28) 31 | CrSizeS = TCursor(-29) 32 | CrSizeSE = TCursor(-30) 33 | CrUpArrow = TCursor(-10) 34 | CrHourGlass = TCursor(-11) 35 | CrDrag = TCursor(-12) 36 | CrNoDrop = TCursor(-13) 37 | CrHSplit = TCursor(-14) 38 | CrVSplit = TCursor(-15) 39 | CrMultiDrag = TCursor(-16) 40 | CrSQLWait = TCursor(-17) 41 | CrNo = TCursor(-18) 42 | CrAppStart = TCursor(-19) 43 | CrHelp = TCursor(-20) 44 | CrHandPoint = TCursor(-21) 45 | CrSizeAll = TCursor(-22) 46 | CrLow = TCursor(-30) 47 | ) 48 | -------------------------------------------------------------------------------- /lcl/win/init.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | //go:build windows 10 | 11 | package win 12 | 13 | var ( 14 | Win32MajorVersion int 15 | Win32MinorVersion int 16 | Win32BuildNumber int 17 | Win32Platform int 18 | ServicePackMajor int 19 | Win32CSDVersion string 20 | ) 21 | 22 | func init() { 23 | initPlatformId() 24 | } 25 | 26 | func initPlatformId() { 27 | var OSVersionInfo TOSVersionInfoEx 28 | var Major, Minor, ServicePack int 29 | if GetVersionEx(&OSVersionInfo) { 30 | if (OSVersionInfo.MajorVersion > 6) || ((OSVersionInfo.MajorVersion == 6) && (OSVersionInfo.MinorVersion > 1)) { 31 | ServicePack = -1 32 | FixWindowsVersion(&Major, &Minor, &ServicePack) 33 | OSVersionInfo.MajorVersion = uint32(Major) 34 | OSVersionInfo.MinorVersion = uint32(Minor) 35 | OSVersionInfo.BuildNumber = 0 36 | } 37 | Win32Platform = int(OSVersionInfo.PlatformId) 38 | Win32MajorVersion = int(OSVersionInfo.MajorVersion) 39 | Win32MinorVersion = int(OSVersionInfo.MinorVersion) 40 | if Win32Platform == VER_PLATFORM_WIN32_WINDOWS { 41 | Win32BuildNumber = int(OSVersionInfo.BuildNumber & 0xFFFF) 42 | } else { 43 | Win32BuildNumber = int(OSVersionInfo.BuildNumber) 44 | } 45 | Win32CSDVersion = GoStr(OSVersionInfo.CSDVersion[:]) 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /lcl/stringsdef.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | package lcl 10 | 11 | func (s *TStrings) AddStrings(list IStrings) { 12 | s.AddStrings3(list, false) 13 | } 14 | 15 | func (s *TStrings) AddStrings2(sArr []string) { 16 | s.BeginUpdate() 17 | defer s.EndUpdate() 18 | for _, v := range sArr { 19 | s.Add(v) 20 | } 21 | } 22 | 23 | func (s *TStrings) AddStrings3(list IStrings, clearFirst bool) { 24 | if list == nil { 25 | return 26 | } 27 | s.BeginUpdate() 28 | defer s.EndUpdate() 29 | if clearFirst { 30 | s.Clear() 31 | } 32 | if s.Count()+list.Count() > s.Capacity() { 33 | s.SetCapacity(s.Count() + list.Count()) 34 | for i := int32(0); i < list.Count(); i++ { 35 | s.AddObject(list.S(i), list.Objects(i)) 36 | } 37 | } 38 | } 39 | 40 | func (s *TStrings) AddPair(name, value string) *TStrings { 41 | return s.AddPair2(name, value, nil) 42 | } 43 | 44 | func (s *TStrings) AddPair2(name, value string, object IObject) *TStrings { 45 | s.AddObject(name+string(s.NameValueSeparator())+value, object) 46 | return s 47 | } 48 | 49 | // 文件流加载。 50 | func (s *TStrings) LoadFromBytes(data []byte) { 51 | if len(data) == 0 { 52 | return 53 | } 54 | mem := NewMemoryStreamFromBytes(data) 55 | defer mem.Free() 56 | mem.SetPosition(0) 57 | s.LoadFromStream(mem) 58 | } 59 | -------------------------------------------------------------------------------- /lcl/api/importFuncsBrowser.go: -------------------------------------------------------------------------------- 1 | package api 2 | 3 | import ( 4 | . "github.com/rarnu/golcl/lcl/types" 5 | ) 6 | 7 | func Browser_Create(obj uintptr, align TAlign) uintptr { 8 | ret, _, _ := getLazyProc("Browser_Create").Call(obj, uintptr(align)) 9 | return ret 10 | } 11 | 12 | func Browser_Free(obj uintptr) { 13 | _, _, _ = getLazyProc("Browser_Free").Call(obj) 14 | } 15 | 16 | func Browser_GetChromiumWindow(obj uintptr) uintptr { 17 | ret, _, _ := getLazyProc("Browser_GetChromiumWindow").Call(obj) 18 | return ret 19 | } 20 | 21 | func Browser_GetChromium(obj uintptr) uintptr { 22 | ret, _, _ := getLazyProc("Browser_GetChromium").Call(obj) 23 | return ret 24 | } 25 | 26 | func Browser_GetOpenLinkPopup(obj uintptr) bool { 27 | ret, _, _ := getLazyProc("Browser_GetOpenLinkPopup").Call(obj) 28 | return DBoolToGoBool(ret) 29 | } 30 | 31 | func Browser_SetOpenLinkPopup(obj uintptr, value bool) { 32 | _, _, _ = getLazyProc("Browser_SetOpenLinkPopup").Call(obj, GoBoolToDBool(value)) 33 | } 34 | 35 | func Browser_SetOnInitComplete(obj uintptr, fn any) { 36 | _, _, _ = getLazyProc("Browser_SetOnInitComplete").Call(obj, addEventToMap(obj, fn)) 37 | } 38 | 39 | func Browser_SetOnAfterCreated(obj uintptr, fn any) { 40 | _, _, _ = getLazyProc("Browser_SetOnAfterCreated").Call(obj, addEventToMap(obj, fn)) 41 | } 42 | 43 | func Browser_SetOnBeforeClose(obj uintptr, fn any) { 44 | _, _, _ = getLazyProc("Browser_SetOnBeforeClose").Call(obj, addEventToMap(obj, fn)) 45 | } 46 | -------------------------------------------------------------------------------- /lcl/rtl/intf_windows.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | package rtl 10 | 11 | import ( 12 | . "github.com/rarnu/golcl/lcl/types" 13 | "github.com/rarnu/golcl/lcl/win" 14 | ) 15 | 16 | // exe自身实例。 17 | // 18 | // Instance of an EXE. 19 | func MainInstance() uintptr { 20 | return win.GetSelfModuleHandle() 21 | } 22 | 23 | func SendMessage(hWd HWND, msg uint32, wParam, lParam uintptr) uintptr { 24 | return win.SendMessage(hWd, msg, wParam, lParam) 25 | } 26 | 27 | func PostMessage(hWd HWND, msg uint32, wParam, lParam uintptr) bool { 28 | return win.PostMessage(hWd, msg, wParam, lParam) != 0 29 | } 30 | 31 | func IsIconic(hWnd HWND) bool { 32 | return win.IsIconic(hWnd) 33 | } 34 | 35 | func IsWindow(hWnd HWND) bool { 36 | return win.IsWindow(hWnd) 37 | } 38 | 39 | func IsZoomed(hWnd HWND) bool { 40 | return win.IsZoomed(hWnd) 41 | } 42 | 43 | func IsWindowVisible(hWnd HWND) bool { 44 | return win.IsWindowVisible(hWnd) 45 | } 46 | 47 | func GetDC(hWnd HWND) HDC { 48 | return win.GetDC(hWnd) 49 | } 50 | 51 | func ReleaseDC(hWnd HWND, dc HDC) int { 52 | return win.ReleaseDC(hWnd, dc) 53 | } 54 | 55 | func SetForegroundWindow(hWnd HWND) bool { 56 | return win.SetForegroundWindow(hWnd) 57 | } 58 | 59 | func WindowFromPoint(point TPoint) HWND { 60 | return win.WindowFromPoint(point) 61 | } 62 | -------------------------------------------------------------------------------- /lcl/stringlistdef.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | package lcl 10 | 11 | func (s *TStringList) AddStrings(list IStrings) { 12 | s.AddStrings3(list, false) 13 | } 14 | 15 | func (s *TStringList) AddStrings2(sArr []string) { 16 | s.BeginUpdate() 17 | defer s.EndUpdate() 18 | for _, v := range sArr { 19 | s.Add(v) 20 | } 21 | } 22 | 23 | func (s *TStringList) AddStrings3(list IStrings, clearFirst bool) { 24 | if list == nil { 25 | return 26 | } 27 | s.BeginUpdate() 28 | defer s.EndUpdate() 29 | if clearFirst { 30 | s.Clear() 31 | } 32 | if s.Count()+list.Count() > s.Capacity() { 33 | s.SetCapacity(s.Count() + list.Count()) 34 | for i := int32(0); i < list.Count(); i++ { 35 | s.AddObject(list.S(i), list.Objects(i)) 36 | } 37 | } 38 | } 39 | 40 | func (s *TStringList) AddPair(name, value string) *TStrings { 41 | return s.AddPair2(name, value, nil) 42 | } 43 | 44 | func (s *TStringList) AddPair2(name, value string, object IObject) *TStrings { 45 | s.AddObject(name+string(s.NameValueSeparator())+value, object) 46 | return AsStrings(s) 47 | } 48 | 49 | // 文件流加载。 50 | func (s *TStringList) LoadFromBytes(data []byte) { 51 | if len(data) == 0 { 52 | return 53 | } 54 | mem := NewMemoryStreamFromBytes(data) 55 | defer mem.Free() 56 | mem.SetPosition(0) 57 | s.LoadFromStream(mem) 58 | } 59 | -------------------------------------------------------------------------------- /lcl/api/importFuncsChartErrorBar.go: -------------------------------------------------------------------------------- 1 | package api 2 | 3 | import ( 4 | . "github.com/rarnu/golcl/lcl/types" 5 | ) 6 | 7 | func ChartErrorBar_Create(obj uintptr) uintptr { 8 | ret, _, _ := getLazyProc("ChartErrorBar_Create").Call(obj) 9 | return ret 10 | } 11 | 12 | func ChartErrorBar_Free(obj uintptr) { 13 | _, _, _ = getLazyProc("ChartErrorBar_Free").Call(obj) 14 | } 15 | 16 | func ChartErrorBar_StaticClassType() TClass { 17 | ret, _, _ := getLazyProc("ChartErrorBar_StaticClassType").Call() 18 | return TClass(ret) 19 | } 20 | 21 | func ChartErrorBar_GetPen(obj uintptr) uintptr { 22 | ret, _, _ := getLazyProc("ChartErrorBar_GetPen").Call(obj) 23 | return ret 24 | } 25 | 26 | func ChartErrorBar_SetPen(obj uintptr, value uintptr) { 27 | _, _, _ = getLazyProc("ChartErrorBar_SetPen").Call(obj, value) 28 | } 29 | 30 | func ChartErrorBar_GetWidth(obj uintptr) int32 { 31 | ret, _, _ := getLazyProc("ChartErrorBar_GetWidth").Call(obj) 32 | return int32(ret) 33 | } 34 | 35 | func ChartErrorBar_SetWidth(obj uintptr, value int32) { 36 | _, _, _ = getLazyProc("ChartErrorBar_SetWidth").Call(obj, uintptr(value)) 37 | } 38 | 39 | func ChartErrorBar_GetVisible(obj uintptr) bool { 40 | ret, _, _ := getLazyProc("ChartErrorBar_GetVisible").Call(obj) 41 | return DBoolToGoBool(ret) 42 | } 43 | 44 | func ChartErrorBar_SetVisible(obj uintptr, value bool) { 45 | _, _, _ = getLazyProc("ChartErrorBar_SetVisible").Call(obj, GoBoolToDBool(value)) 46 | } 47 | 48 | func ChartErrorBar_SetOwner(obj uintptr, AOwner uintptr) { 49 | _, _, _ = getLazyProc("ChartErrorBar_SetOwner").Call(obj, AOwner) 50 | } 51 | -------------------------------------------------------------------------------- /lcl/imagelistdef.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | package lcl 10 | 11 | import ( 12 | . "github.com/rarnu/golcl/lcl/api" 13 | . "github.com/rarnu/golcl/lcl/types" 14 | ) 15 | 16 | func (i *TImageList) Draw(canvas IObject, x, y, index int32, enabled bool) { 17 | ImageList_Draw1(i.instance, CheckPtr(canvas), x, y, index, enabled) 18 | } 19 | 20 | func (i *TImageList) Draw2(canvas IObject, x, y, index int32, drawingStyle TDrawingStyle, imageType TImageType, enabled bool) { 21 | ImageList_Draw2(i.instance, CheckPtr(canvas), x, y, index, drawingStyle, imageType, enabled) 22 | } 23 | 24 | func (i *TImageList) DrawOverlay(canvas IObject, x, y, imageIndex int32, overlay uint8, enabled bool) { 25 | ImageList_DrawOverlay1(i.instance, CheckPtr(canvas), x, y, imageIndex, overlay, enabled) 26 | } 27 | 28 | func (i *TImageList) DrawOverlay2(canvas IObject, x, y, imageIndex int32, overlay uint8, drawingStyle TDrawingStyle, imageType TImageType, enabled bool) { 29 | ImageList_DrawOverlay2(i.instance, CheckPtr(canvas), x, y, imageIndex, overlay, drawingStyle, imageType, enabled) 30 | } 31 | 32 | func (i *TImageList) GetIcon(index int32, image IObject) { 33 | ImageList_GetIcon1(i.instance, index, CheckPtr(image)) 34 | } 35 | 36 | func (i *TImageList) GetIcon2(index int32, image IObject, drawingStyle TDrawingStyle, imageType TImageType) { 37 | ImageList_GetIcon2(i.instance, index, CheckPtr(image), drawingStyle, imageType) 38 | } 39 | -------------------------------------------------------------------------------- /chart/dumper.go: -------------------------------------------------------------------------------- 1 | package chart 2 | 3 | import ( 4 | "github.com/rarnu/golcl/lcl" 5 | "github.com/rarnu/golcl/lcl/bitmap" 6 | "github.com/vdobler/chart" 7 | "github.com/vdobler/chart/imgg" 8 | "github.com/vdobler/chart/txtg" 9 | "image" 10 | "image/color" 11 | "image/draw" 12 | ) 13 | 14 | type Dumper struct { 15 | N, M, W, H, Cnt int 16 | I *image.RGBA 17 | image *lcl.TImage 18 | changeSize bool 19 | } 20 | 21 | func NewDumper(col, row, w, h int, img *lcl.TImage, changeSize bool) *Dumper { 22 | dumper := Dumper{N: col, M: row, W: w, H: h} 23 | dumper.image = img 24 | dumper.changeSize = changeSize 25 | dumper.I = image.NewRGBA(image.Rect(0, 0, col*w, row*h)) 26 | bg := image.NewUniform(color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff}) 27 | draw.Draw(dumper.I, dumper.I.Bounds(), bg, image.ZP, draw.Src) 28 | 29 | return &dumper 30 | } 31 | func (d *Dumper) Close() { 32 | if d.image != nil { 33 | if d.changeSize { 34 | d.image.Picture().Clear() 35 | // 必须先改大小才能画,否则画出框 36 | w := int32(d.N * d.W) 37 | h := int32(d.M * d.H) 38 | d.image.SetWidth(w) 39 | d.image.SetHeight(h) 40 | } 41 | pngObj, err := bitmap.ToPngImage(d.I) 42 | if err == nil && pngObj != nil { 43 | defer pngObj.Free() 44 | d.image.Canvas().Draw(0, 0, pngObj) 45 | } 46 | } 47 | } 48 | 49 | func (d *Dumper) Plot(c chart.Chart) { 50 | row, col := d.Cnt/d.N, d.Cnt%d.N 51 | igr := imgg.AddTo(d.I, col*d.W, row*d.H, d.W, d.H, color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff}, nil, nil) 52 | c.Plot(igr) 53 | tgr := txtg.New(100, 30) 54 | c.Plot(tgr) 55 | d.Cnt++ 56 | } 57 | -------------------------------------------------------------------------------- /lcl/formres.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | package lcl 10 | 11 | import ( 12 | "errors" 13 | "reflect" 14 | "strings" 15 | "sync" 16 | ) 17 | 18 | type formResItem struct { 19 | ClassName string 20 | Data *[]byte 21 | } 22 | 23 | var ( 24 | // 用于自动查找并加载资源的 25 | formResMap sync.Map 26 | ) 27 | 28 | func getClassName(aClass any) string { 29 | className := "" 30 | switch aClass.(type) { 31 | case string: 32 | className = aClass.(string) 33 | default: 34 | temp := strings.Split(reflect.TypeOf(aClass).String(), ".") 35 | if len(temp) > 0 { 36 | className = temp[len(temp)-1] 37 | } 38 | } 39 | if len(className) == 0 { 40 | return "" 41 | } 42 | return strings.ToUpper(className) 43 | } 44 | 45 | // 注册一个Form的资源 46 | // 此种方式用于不指定Form资源,直接通过类名查找方式 47 | func RegisterFormResource(aClass any, data *[]byte) error { 48 | className := getClassName(aClass) 49 | if className == "" || data == nil { 50 | return errors.New("className and data cannot be empty") 51 | } 52 | // Delphi中不区分大小写的,所以统一转为大写 53 | formResMap.Store(className, &formResItem{ClassName: className, Data: data}) 54 | return nil 55 | } 56 | 57 | // 查找对应的Form资源 58 | func findFormResource(aClass any) (*formResItem, error) { 59 | className := getClassName(aClass) 60 | if className != "" { 61 | if val, ok := formResMap.Load(className); ok { 62 | return val.(*formResItem), nil 63 | } 64 | } 65 | return nil, errors.New("not found") 66 | } 67 | -------------------------------------------------------------------------------- /go.sum: -------------------------------------------------------------------------------- 1 | github.com/ajstarks/svgo v0.0.0-20181006003313-6ce6a3bcf6cd/go.mod h1:K08gAheRH3/J6wwsYMMT4xOr94bZjxIelGM0+d/wbFw= 2 | github.com/go-gl/gl v0.0.0-20180407155706-68e253793080/go.mod h1:482civXOzJJCPzJ4ZOX/pwvXBWSnzD4OKMdH4ClKGbk= 3 | github.com/go-gl/glfw v0.0.0-20180426074136-46a8d530c326/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= 4 | github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 h1:DACJavvAHhabrF08vX0COfcOBJRhZ8lUbR+ZWIs0Y5g= 5 | github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k= 6 | github.com/jung-kurt/gofpdf v1.0.0/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes= 7 | github.com/llgcode/draw2d v0.0.0-20180825133448-f52c8a71aff0 h1:2vp6ESimuT8pCuZHThVyV0hlfa9oPL06HnGCL9pbUgc= 8 | github.com/llgcode/draw2d v0.0.0-20180825133448-f52c8a71aff0/go.mod h1:mVa0dA29Db2S4LVqDYLlsePDzRJLDfdhVZiI15uY0FA= 9 | github.com/llgcode/ps v0.0.0-20150911083025-f1443b32eedb h1:61ndUreYSlWFeCY44JxDDkngVoI7/1MVhEl98Nm0KOk= 10 | github.com/llgcode/ps v0.0.0-20150911083025-f1443b32eedb/go.mod h1:1l8ky+Ew27CMX29uG+a2hNOKpeNYEQjjtiALiBlFQbY= 11 | github.com/vdobler/chart v1.0.0 h1:ySWmgHJtBsb7/SItvKb+VM3Nxb0SksDIjZhSbiK+Wi0= 12 | github.com/vdobler/chart v1.0.0/go.mod h1:gRwLtqIJLDw1CkK9kxJXv3X9OaMfM4dYsbZtWtVLxvM= 13 | golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs= 14 | golang.org/x/image v0.0.0-20181030002151-69cc3646b96e h1:LpHV5J9Rec5OYn+RZFfNenrW109yUVSoKjGOgmKKhxE= 15 | golang.org/x/image v0.0.0-20181030002151-69cc3646b96e/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs= 16 | -------------------------------------------------------------------------------- /lcl/api/importFuncsObject.go: -------------------------------------------------------------------------------- 1 | package api 2 | 3 | import ( 4 | . "github.com/rarnu/golcl/lcl/types" 5 | ) 6 | 7 | //--------------------------- TObject --------------------------- 8 | 9 | func Object_Create() uintptr { 10 | ret, _, _ := getLazyProc("Object_Create").Call() 11 | return ret 12 | } 13 | 14 | func Object_Free(obj uintptr) { 15 | _, _, _ = getLazyProc("Object_Free").Call(obj) 16 | } 17 | 18 | func Object_ClassType(obj uintptr) TClass { 19 | ret, _, _ := getLazyProc("Object_ClassType").Call(obj) 20 | return TClass(ret) 21 | } 22 | 23 | func Object_ClassName(obj uintptr) string { 24 | ret, _, _ := getLazyProc("Object_ClassName").Call(obj) 25 | return DStrToGoStr(ret) 26 | } 27 | 28 | func Object_InstanceSize(obj uintptr) int32 { 29 | ret, _, _ := getLazyProc("Object_InstanceSize").Call(obj) 30 | return int32(ret) 31 | } 32 | 33 | func Object_InheritsFrom(obj uintptr, AClass TClass) bool { 34 | ret, _, _ := getLazyProc("Object_InheritsFrom").Call(obj, uintptr(AClass)) 35 | return DBoolToGoBool(ret) 36 | } 37 | 38 | func Object_Equals(obj uintptr, Obj uintptr) bool { 39 | ret, _, _ := getLazyProc("Object_Equals").Call(obj, Obj) 40 | return DBoolToGoBool(ret) 41 | } 42 | 43 | func Object_GetHashCode(obj uintptr) int32 { 44 | ret, _, _ := getLazyProc("Object_GetHashCode").Call(obj) 45 | return int32(ret) 46 | } 47 | 48 | func Object_ToString(obj uintptr) string { 49 | ret, _, _ := getLazyProc("Object_ToString").Call(obj) 50 | return DStrToGoStr(ret) 51 | } 52 | 53 | func Object_StaticClassType() TClass { 54 | r, _, _ := getLazyProc("Object_StaticClassType").Call() 55 | return TClass(r) 56 | } 57 | -------------------------------------------------------------------------------- /lcl/iwincontrol.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | package lcl 10 | 11 | import . "github.com/rarnu/golcl/lcl/types" 12 | 13 | type IWinControl interface { 14 | IControl 15 | Handle() HWND 16 | SetHandle(HWND) 17 | 18 | TabStop() bool 19 | SetTabStop(bool) 20 | 21 | TabOrder() TTabOrder 22 | SetTabOrder(TTabOrder) 23 | 24 | Showing() bool 25 | 26 | ParentWindow() HWND 27 | SetParentWindow(HWND) 28 | 29 | ParentDoubleBuffered() bool 30 | SetParentDoubleBuffered(bool) 31 | 32 | ControlCount() int32 33 | Controls(index int32) *TControl 34 | 35 | Brush() *TBrush 36 | //Padding() *TPadding 37 | 38 | SetFocus() 39 | Update() 40 | 41 | CanFocus() bool 42 | ContainsControl(IControl) bool 43 | DisableAlign() 44 | DockClientCount() int32 45 | DockClients(int32) *TControl 46 | 47 | DoubleBuffered() bool 48 | SetDoubleBuffered(bool) 49 | 50 | EnableAlign() 51 | 52 | FindChildControl(string) *TControl 53 | FlipChildren(bool) 54 | 55 | Focused() bool 56 | 57 | InsertControl(IControl) 58 | RemoveControl(IControl) 59 | 60 | ScaleBy(M int32, D int32) 61 | ScrollBy(DeltaX int32, DeltaY int32) 62 | 63 | MouseInClient() bool 64 | AlignDisabled() bool 65 | //Invalidate() 66 | 67 | UpdateControlState() 68 | 69 | HandleAllocated() bool 70 | PaintTo(DC HDC, X int32, Y int32) 71 | 72 | ClientToScreen(Point TPoint) TPoint 73 | ClientToParent(Point TPoint, AParent IWinControl) TPoint 74 | 75 | UseDockManager() bool 76 | SetUseDockManager(value bool) 77 | } 78 | -------------------------------------------------------------------------------- /lcl/win/msvcrtdll.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | //go:build windows 10 | 11 | package win 12 | 13 | import ( 14 | "syscall" 15 | "unsafe" 16 | ) 17 | 18 | var ( 19 | // msvcrt.dll 20 | msvcrtdll = syscall.NewLazyDLL("msvcrt.dll") 21 | 22 | _memcpy = msvcrtdll.NewProc("memcpy") 23 | _memset = msvcrtdll.NewProc("memset") 24 | _malloc = msvcrtdll.NewProc("malloc") 25 | _realloc = msvcrtdll.NewProc("realloc") 26 | _free = msvcrtdll.NewProc("free") 27 | _system = msvcrtdll.NewProc("system") 28 | ) 29 | 30 | // Memcpy 内存拷贝 31 | func Memcpy(dest, src, count uintptr) uintptr { 32 | r, _, _ := _memcpy.Call(dest, src, count) 33 | return r 34 | } 35 | 36 | // Memset 将指定内存区值默认为val中的,一般用于清0也是是 Memset(ptr, 0, size) 37 | func Memset(dest uintptr, val int, count uintptr) uintptr { 38 | r, _, _ := _memset.Call(dest, uintptr(val), count) 39 | return r 40 | } 41 | 42 | // Malloc 分配内存,此为手动管理,分配后要使用Free释放 43 | func Malloc(size uintptr) uintptr { 44 | r, _, _ := _malloc.Call(size) 45 | return r 46 | } 47 | 48 | // Realloc 重新分配内存,此为手动管理,分配后要使用Free释放 49 | func Realloc(P, NewSize uintptr) uintptr { 50 | r, _, _ := _realloc.Call(P, NewSize) 51 | return r 52 | } 53 | 54 | // Free 释放内存 55 | func Free(pBlock uintptr) { 56 | _free.Call(pBlock) 57 | } 58 | 59 | // System 系统命令 60 | func System(aCommand string) int { 61 | if aCommand == "" { 62 | return -1 63 | } 64 | ptr := uintptr(unsafe.Pointer(&UTF8ToANSI(aCommand)[0])) 65 | r, _, _ := _system.Call(ptr) 66 | return int(r) 67 | } 68 | -------------------------------------------------------------------------------- /lcl/api/importFuncsSynBatSyn.go: -------------------------------------------------------------------------------- 1 | package api 2 | 3 | import ( 4 | . "github.com/rarnu/golcl/lcl/types" 5 | ) 6 | 7 | func SynBatSyn_Create(owner uintptr) uintptr { 8 | r, _, _ := getLazyProc("SynBatSyn_Create").Call(owner) 9 | return r 10 | } 11 | 12 | func SynBatSyn_Free(obj uintptr) { 13 | _, _, _ = getLazyProc("SynBatSyn_Free").Call(obj) 14 | } 15 | 16 | func SynBatSyn_StaticClassType() TClass { 17 | r, _, _ := getLazyProc("SynBatSyn_StaticClassType").Call() 18 | return TClass(r) 19 | } 20 | 21 | func SynBatSyn_GetEnabled(obj uintptr) bool { 22 | r, _, _ := getLazyProc("SynBatSyn_GetEnabled").Call(obj) 23 | return DBoolToGoBool(r) 24 | } 25 | 26 | func SynBatSyn_SetEnabled(obj uintptr, value bool) { 27 | _, _, _ = getLazyProc("SynBatSyn_SetEnabled").Call(obj, GoBoolToDBool(value)) 28 | } 29 | 30 | func SynBatSyn_GetCommentAttri(obj uintptr) uintptr { 31 | r, _, _ := getLazyProc("SynBatSyn_GetCommentAttri").Call(obj) 32 | return r 33 | } 34 | 35 | func SynBatSyn_GetIdentifierAttri(obj uintptr) uintptr { 36 | r, _, _ := getLazyProc("SynBatSyn_GetIdentifierAttri").Call(obj) 37 | return r 38 | } 39 | 40 | func SynBatSyn_GetKeyAttri(obj uintptr) uintptr { 41 | r, _, _ := getLazyProc("SynBatSyn_GetKeyAttri").Call(obj) 42 | return r 43 | } 44 | 45 | func SynBatSyn_GetNumberAttri(obj uintptr) uintptr { 46 | r, _, _ := getLazyProc("SynBatSyn_GetNumberAttri").Call(obj) 47 | return r 48 | } 49 | 50 | func SynBatSyn_GetSpaceAttri(obj uintptr) uintptr { 51 | r, _, _ := getLazyProc("SynBatSyn_GetSpaceAttri").Call(obj) 52 | return r 53 | } 54 | 55 | func SynBatSyn_GetVariableAttri(obj uintptr) uintptr { 56 | r, _, _ := getLazyProc("SynBatSyn_GetVariableAttri").Call(obj) 57 | return r 58 | } 59 | -------------------------------------------------------------------------------- /lcl/rtl/version/osversion.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | package version 10 | 11 | type TArchitecture uint32 12 | 13 | const ( 14 | ArIntelX86 TArchitecture = iota + 0 15 | ArIntelX64 16 | ArARM32 17 | ArARM64 18 | ) 19 | 20 | type TPlatform uint32 21 | 22 | const ( 23 | PfWindows TPlatform = iota + 0 24 | PfMacOS 25 | PfiOS 26 | PfAndroid 27 | PfWinRT 28 | PfLinux 29 | ) 30 | 31 | type TOSVersion struct { 32 | Name string 33 | Build int 34 | Major int 35 | Minor int 36 | ServicePackMajor int 37 | ServicePackMinor int 38 | Architecture TArchitecture 39 | Platform TPlatform 40 | 41 | // linux: PrettyName, LibCVersionMajor, LibCVersionMinor 42 | PrettyName string 43 | LibCVersionMajor int 44 | LibCVersionMinor int 45 | 46 | fmtVerString string 47 | } 48 | 49 | var OSVersion TOSVersion 50 | 51 | // CheckMajor 检测系统主版本号 52 | func (v *TOSVersion) CheckMajor(AMajor int) bool { 53 | return v.Major >= AMajor 54 | } 55 | 56 | // CheckMajorMinor 检测系统主版本和子版本号 57 | func (v *TOSVersion) CheckMajorMinor(AMajor, AMinor int) bool { 58 | return v.Major > AMajor || (v.Major == AMajor && v.Minor >= AMinor) 59 | } 60 | 61 | func (v *TOSVersion) CheckMajorMinorServicePackMajor(AMajor, AMinor, AServicePackMajor int) bool { 62 | return v.Major > AMajor || (v.Major == AMajor && v.Minor > AMinor) || 63 | ((v.Major == AMajor && v.Minor == AMinor) && (v.ServicePackMajor >= AServicePackMajor)) 64 | } 65 | 66 | // ToString 版本信息 67 | func (v *TOSVersion) ToString() string { 68 | return v.fmtVerString 69 | } 70 | -------------------------------------------------------------------------------- /lcl/api/importFuncsException.go: -------------------------------------------------------------------------------- 1 | package api 2 | 3 | import ( 4 | . "github.com/rarnu/golcl/lcl/types" 5 | ) 6 | 7 | //--------------------------- Exception --------------------------- 8 | 9 | func Exception_ToString(obj uintptr) string { 10 | ret, _, _ := getLazyProc("Exception_ToString").Call(obj) 11 | return DStrToGoStr(ret) 12 | } 13 | 14 | func Exception_ClassType(obj uintptr) TClass { 15 | ret, _, _ := getLazyProc("Exception_ClassType").Call(obj) 16 | return TClass(ret) 17 | } 18 | 19 | func Exception_ClassName(obj uintptr) string { 20 | ret, _, _ := getLazyProc("Exception_ClassName").Call(obj) 21 | return DStrToGoStr(ret) 22 | } 23 | 24 | func Exception_InstanceSize(obj uintptr) int32 { 25 | ret, _, _ := getLazyProc("Exception_InstanceSize").Call(obj) 26 | return int32(ret) 27 | } 28 | 29 | func Exception_InheritsFrom(obj uintptr, AClass TClass) bool { 30 | ret, _, _ := getLazyProc("Exception_InheritsFrom").Call(obj, uintptr(AClass)) 31 | return DBoolToGoBool(ret) 32 | } 33 | 34 | func Exception_Equals(obj uintptr, Obj uintptr) bool { 35 | ret, _, _ := getLazyProc("Exception_Equals").Call(obj, Obj) 36 | return DBoolToGoBool(ret) 37 | } 38 | 39 | func Exception_GetHashCode(obj uintptr) int32 { 40 | ret, _, _ := getLazyProc("Exception_GetHashCode").Call(obj) 41 | return int32(ret) 42 | } 43 | 44 | func Exception_GetMessage(obj uintptr) string { 45 | ret, _, _ := getLazyProc("Exception_GetMessage").Call(obj) 46 | return DStrToGoStr(ret) 47 | } 48 | 49 | func Exception_SetMessage(obj uintptr, value string) { 50 | _, _, _ = getLazyProc("Exception_SetMessage").Call(obj, GoStrToDStr(value)) 51 | } 52 | 53 | func Exception_StaticClassType() TClass { 54 | r, _, _ := getLazyProc("Exception_StaticClassType").Call() 55 | return TClass(r) 56 | } 57 | -------------------------------------------------------------------------------- /lcl/clipboarddef.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | package lcl 10 | 11 | import ( 12 | . "github.com/rarnu/golcl/lcl/api" 13 | "github.com/rarnu/golcl/lcl/types" 14 | ) 15 | 16 | func SetClipboard(newClipboard IObject) *TClipboard { 17 | return AsClipboard(DSetClipboard(CheckPtr(newClipboard))) 18 | } 19 | 20 | func RegisterClipboardFormat(aFormat string) types.TClipboardFormat { 21 | return DRegisterClipboardFormat(aFormat) 22 | } 23 | 24 | func PredefinedClipboardFormat(aFormat types.TPredefinedClipboardFormat) types.TClipboardFormat { 25 | return DPredefinedClipboardFormat(aFormat) 26 | } 27 | 28 | func (c *TClipboard) HasFormat(aFormatID types.TClipboardFormat) bool { 29 | return Clipboard_HasFormat(c.instance, aFormatID) 30 | } 31 | 32 | func (c *TClipboard) GetAsHtml(ExtractFragmentOnly bool) string { 33 | return Clipboard_GetAsHtml(c.instance, ExtractFragmentOnly) 34 | } 35 | 36 | func (c *TClipboard) GetTextBuf(Buffer *string, BufSize int32) int32 { 37 | return Clipboard_GetTextBuf(c.instance, Buffer, BufSize) 38 | } 39 | 40 | func (c *TClipboard) AsText() string { 41 | mem := NewMemoryStream() 42 | defer mem.Free() 43 | if c.GetFormat(PredefinedClipboardFormat(types.PcfText), mem) { 44 | size := mem.Size() 45 | mem.SetPosition(0) 46 | if size > 0 { 47 | n, buff := mem.Read(int32(size)) 48 | if n > 0 && buff[len(buff)-1] == 0 { 49 | return string(buff[:len(buff)-1]) 50 | } else { 51 | return string(buff) 52 | } 53 | } 54 | } 55 | return "" 56 | //return Clipboard_GetAsText(c.instance) 57 | } 58 | 59 | func (c *TClipboard) SetAsText(value string) { 60 | Clipboard_SetAsText(c.instance, value) 61 | } 62 | -------------------------------------------------------------------------------- /lcl/api/importFuncsSynBasicSyn.go: -------------------------------------------------------------------------------- 1 | package api 2 | 3 | import ( 4 | . "github.com/rarnu/golcl/lcl/types" 5 | ) 6 | 7 | func SynVBSyn_Create(owner uintptr) uintptr { 8 | r, _, _ := getLazyProc("SynVBSyn_Create").Call(owner) 9 | return r 10 | } 11 | 12 | func SynVBSyn_Free(obj uintptr) { 13 | _, _, _ = getLazyProc("SynVBSyn_Free").Call(obj) 14 | } 15 | 16 | func SynVBSyn_StaticClassType() TClass { 17 | r, _, _ := getLazyProc("SynVBSyn_StaticClassType").Call() 18 | return TClass(r) 19 | } 20 | 21 | func SynVBSyn_GetEnabled(obj uintptr) bool { 22 | r, _, _ := getLazyProc("SynVBSyn_GetEnabled").Call(obj) 23 | return DBoolToGoBool(r) 24 | } 25 | 26 | func SynVBSyn_SetEnabled(obj uintptr, value bool) { 27 | _, _, _ = getLazyProc("SynVBSyn_SetEnabled").Call(obj, GoBoolToDBool(value)) 28 | } 29 | 30 | func SynVBSyn_GetCommentAttri(obj uintptr) uintptr { 31 | r, _, _ := getLazyProc("SynVBSyn_GetCommentAttri").Call(obj) 32 | return r 33 | } 34 | 35 | func SynVBSyn_GetIdentifierAttri(obj uintptr) uintptr { 36 | r, _, _ := getLazyProc("SynVBSyn_GetIdentifierAttri").Call(obj) 37 | return r 38 | } 39 | 40 | func SynVBSyn_GetKeyAttri(obj uintptr) uintptr { 41 | r, _, _ := getLazyProc("SynVBSyn_GetKeyAttri").Call(obj) 42 | return r 43 | } 44 | 45 | func SynVBSyn_GetNumberAttri(obj uintptr) uintptr { 46 | r, _, _ := getLazyProc("SynVBSyn_GetNumberAttri").Call(obj) 47 | return r 48 | } 49 | 50 | func SynVBSyn_GetSpaceAttri(obj uintptr) uintptr { 51 | r, _, _ := getLazyProc("SynVBSyn_GetSpaceAttri").Call(obj) 52 | return r 53 | } 54 | 55 | func SynVBSyn_GetStringAttri(obj uintptr) uintptr { 56 | r, _, _ := getLazyProc("SynVBSyn_GetStringAttri").Call(obj) 57 | return r 58 | } 59 | 60 | func SynVBSyn_GetSymbolAttri(obj uintptr) uintptr { 61 | r, _, _ := getLazyProc("SynVBSyn_GetSymbolAttri").Call(obj) 62 | return r 63 | } 64 | -------------------------------------------------------------------------------- /lcl/types/consts.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | package types 10 | 11 | // MessageBox or MessageDlg 返回值 12 | const ( 13 | IdOK = 1 14 | IdCancel = 2 15 | IdAbort = 3 16 | IdRetry = 4 17 | IdIgnore = 5 18 | IdYes = 6 19 | IdNo = 7 20 | IdClose = 8 21 | IdHelp = 9 22 | IdTryAgain = 10 23 | IdContinue = 11 24 | MrNone = 0 25 | MrOk = IdOK 26 | MrCancel = IdCancel 27 | MrAbort = IdAbort 28 | MrRetry = IdRetry 29 | MrIgnore = IdIgnore 30 | MrYes = IdYes 31 | MrNo = IdNo 32 | MrClose = IdClose 33 | MrHelp = IdHelp 34 | MrTryAgain = IdTryAgain 35 | MrContinue = IdContinue 36 | MrAll = MrContinue + 1 37 | MrNoToAll = MrAll + 1 38 | MrYesToAll = MrNoToAll + 1 39 | ) 40 | 41 | // Predefined Clipboard Formats 42 | const ( 43 | CF_BITMAP = 2 44 | CF_DIB = 8 45 | CF_PALETTE = 9 46 | CF_ENHMETAFILE = 14 47 | CF_METAFILEPICT = 3 48 | CF_OEMTEXT = 7 49 | CF_TEXT = 1 50 | CF_UNICODETEXT = 13 51 | CF_DIF = 5 52 | CF_DSPBITMAP = 130 53 | CF_DSPENHMETAFILE = 142 54 | CF_DSPMETAFILEPICT = 131 55 | CF_DSPTEXT = 129 56 | CF_GDIOBJFIRST = 768 57 | CF_GDIOBJLAST = 1023 58 | CF_HDROP = 15 59 | CF_LOCALE = 16 60 | CF_OWNERDISPLAY = 128 61 | CF_PENDATA = 10 62 | CF_PRIVATEFIRST = 512 63 | CF_PRIVATELAST = 767 64 | CF_RIFF = 11 65 | CF_SYLK = 4 66 | CF_WAVE = 12 67 | CF_TIFF = 6 68 | 69 | // CF_PICTURE custom 70 | CF_PICTURE = 700 71 | CF_HTML = 701 72 | CF_COMPONENT = 702 73 | ) 74 | -------------------------------------------------------------------------------- /lcl/api/imagelistdef.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | package api 10 | 11 | import ( 12 | . "github.com/rarnu/golcl/lcl/types" 13 | ) 14 | 15 | func ImageList_Draw1(obj uintptr, canvas uintptr, x, y, index int32, enabled bool) { 16 | _, _, _ = imageList_Draw1.Call(obj, canvas, uintptr(x), uintptr(y), uintptr(index), GoBoolToDBool(enabled)) 17 | } 18 | 19 | func ImageList_Draw2(obj uintptr, canvas uintptr, x, y, index int32, drawingStyle TDrawingStyle, 20 | imageType TImageType, enabled bool) { 21 | _, _, _ = imageList_Draw2.Call(obj, canvas, uintptr(x), uintptr(y), uintptr(index), uintptr(drawingStyle), uintptr(imageType), GoBoolToDBool(enabled)) 22 | } 23 | 24 | func ImageList_DrawOverlay1(obj uintptr, canvas uintptr, x, y, imageIndex int32, overlay uint8, enabled bool) { 25 | _, _, _ = imageList_DrawOverlay1.Call(obj, canvas, uintptr(x), uintptr(y), uintptr(imageIndex), uintptr(overlay), GoBoolToDBool(enabled)) 26 | } 27 | 28 | func ImageList_DrawOverlay2(obj, canvas uintptr, x, y, imageIndex int32, overlay uint8, 29 | drawingStyle TDrawingStyle, imageType TImageType, enabled bool) { 30 | _, _, _ = imageList_DrawOverlay2.Call(obj, canvas, uintptr(x), uintptr(y), uintptr(imageIndex), uintptr(overlay), uintptr(drawingStyle), uintptr(imageType), GoBoolToDBool(enabled)) 31 | } 32 | 33 | func ImageList_GetIcon1(obj uintptr, index int32, image uintptr) { 34 | _, _, _ = imageList_GetIcon1.Call(obj, uintptr(index), image) 35 | } 36 | 37 | func ImageList_GetIcon2(obj uintptr, index int32, image uintptr, drawingStyle TDrawingStyle, imageType TImageType) { 38 | _, _, _ = imageList_GetIcon2.Call(obj, uintptr(index), image, uintptr(drawingStyle), uintptr(imageType)) 39 | } 40 | -------------------------------------------------------------------------------- /lcl/api/importFuncsSynTexSyn.go: -------------------------------------------------------------------------------- 1 | package api 2 | 3 | import ( 4 | . "github.com/rarnu/golcl/lcl/types" 5 | ) 6 | 7 | func SynTeXSyn_Create(owner uintptr) uintptr { 8 | r, _, _ := getLazyProc("SynTeXSyn_Create").Call(owner) 9 | return r 10 | } 11 | 12 | func SynTeXSyn_Free(obj uintptr) { 13 | _, _, _ = getLazyProc("SynTeXSyn_Free").Call(obj) 14 | } 15 | 16 | func SynTeXSyn_StaticClassType() TClass { 17 | r, _, _ := getLazyProc("SynTeXSyn_StaticClassType").Call() 18 | return TClass(r) 19 | } 20 | 21 | func SynTeXSyn_GetEnabled(obj uintptr) bool { 22 | r, _, _ := getLazyProc("SynTeXSyn_GetEnabled").Call(obj) 23 | return DBoolToGoBool(r) 24 | } 25 | 26 | func SynTeXSyn_SetEnabled(obj uintptr, value bool) { 27 | _, _, _ = getLazyProc("SynTeXSyn_SetEnabled").Call(obj, GoBoolToDBool(value)) 28 | } 29 | 30 | func SynTeXSyn_GetCommentAttri(obj uintptr) uintptr { 31 | r, _, _ := getLazyProc("SynTeXSyn_GetCommentAttri").Call(obj) 32 | return r 33 | } 34 | 35 | func SynTeXSyn_GetTextAttri(obj uintptr) uintptr { 36 | r, _, _ := getLazyProc("SynTeXSyn_GetTextAttri").Call(obj) 37 | return r 38 | } 39 | 40 | func SynTeXSyn_GetControlSequenceAttri(obj uintptr) uintptr { 41 | r, _, _ := getLazyProc("SynTeXSyn_GetControlSequenceAttri").Call(obj) 42 | return r 43 | } 44 | 45 | func SynTeXSyn_GetMathmodeAttri(obj uintptr) uintptr { 46 | r, _, _ := getLazyProc("SynTeXSyn_GetMathmodeAttri").Call(obj) 47 | return r 48 | } 49 | 50 | func SynTeXSyn_GetSpaceAttri(obj uintptr) uintptr { 51 | r, _, _ := getLazyProc("SynTeXSyn_GetSpaceAttri").Call(obj) 52 | return r 53 | } 54 | 55 | func SynTeXSyn_GetBraceAttri(obj uintptr) uintptr { 56 | r, _, _ := getLazyProc("SynTeXSyn_GetBraceAttri").Call(obj) 57 | return r 58 | } 59 | 60 | func SynTeXSyn_GetBracketAttri(obj uintptr) uintptr { 61 | r, _, _ := getLazyProc("SynTeXSyn_GetBracketAttri").Call(obj) 62 | return r 63 | } 64 | -------------------------------------------------------------------------------- /lcl/api/clipboarddef.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | package api 10 | 11 | import ( 12 | "unsafe" 13 | 14 | "github.com/rarnu/golcl/lcl/types" 15 | ) 16 | 17 | func Clipboard_Instance() uintptr { 18 | r, _, _ := clipboard_Instance.Call() 19 | return r 20 | } 21 | 22 | func Clipboard_HasFormat(obj uintptr, aFormatID types.TClipboardFormat) bool { 23 | r, _, _ := clipboard_HasFormat.Call(obj, aFormatID) 24 | return r != 0 25 | } 26 | 27 | func Clipboard_GetTextBuf(obj uintptr, Buffer *string, BufSize int32) int32 { 28 | if BufSize <= 0 { 29 | return 0 30 | } 31 | buff := make([]byte, BufSize) 32 | ret, _, _ := clipboard_GetTextBuf.Call(obj, uintptr(unsafe.Pointer(&buff[0])), uintptr(BufSize)) 33 | if int(ret) < len(buff) { 34 | *Buffer = string(buff[:ret]) 35 | } 36 | return int32(ret) 37 | } 38 | 39 | func Clipboard_GetAsText(obj uintptr) string { 40 | ret, _, _ := clipboard_GetAsText.Call(obj) 41 | return DStrToGoStr(ret) 42 | } 43 | 44 | func Clipboard_SetAsText(obj uintptr, value string) { 45 | _, _, _ = clipboard_SetAsText.Call(obj, GoStrToDStr(value)) 46 | } 47 | 48 | func Clipboard_GetAsHtml(obj uintptr, ExtractFragmentOnly bool) string { 49 | ret, _, _ := clipboard_GetAsHtml.Call(obj, GoBoolToDBool(ExtractFragmentOnly)) 50 | return DStrToGoStr(ret) 51 | } 52 | 53 | func DSetClipboard(obj uintptr) uintptr { 54 | r, _, _ := dSetClipboard.Call(obj) 55 | return r 56 | } 57 | 58 | func DRegisterClipboardFormat(aFormat string) types.TClipboardFormat { 59 | r, _, _ := dRegisterClipboardFormat.Call(GoStrToDStr(aFormat)) 60 | return r 61 | } 62 | 63 | func DPredefinedClipboardFormat(aFormat types.TPredefinedClipboardFormat) types.TClipboardFormat { 64 | r, _, _ := dPredefinedClipboardFormat.Call(uintptr(aFormat)) 65 | return r 66 | } 67 | -------------------------------------------------------------------------------- /test/lcl_test.go: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | import ( 4 | "github.com/rarnu/golcl/lcl" 5 | "github.com/rarnu/golcl/lcl/types" 6 | "testing" 7 | ) 8 | 9 | func TestLCL(t *testing.T) { 10 | lcl.Application.Initialize() 11 | lcl.Application.SetMainFormOnTaskBar(true) 12 | lcl.Application.CreateForm(&MainForm) 13 | lcl.Application.CreateForm(&AboutForm) 14 | lcl.Application.Run() 15 | } 16 | 17 | type TMainForm struct { 18 | *lcl.TForm 19 | Btn1 *lcl.TButton 20 | Lbl *lcl.TLabel 21 | Edt *lcl.TSynEdit 22 | } 23 | 24 | type TAboutForm struct { 25 | *lcl.TForm 26 | Btn1 *lcl.TButton 27 | } 28 | 29 | var MainForm *TMainForm 30 | var AboutForm *TAboutForm 31 | 32 | func (f *TMainForm) OnFormCreate(_ lcl.IObject) { 33 | 34 | f.SetCaption("Main") 35 | f.SetPosition(types.PoScreenCenter) 36 | f.SetWidth(600) 37 | f.SetHeight(400) 38 | 39 | f.Btn1 = lcl.NewButton(f) 40 | f.Btn1.SetParent(f) 41 | f.Btn1.SetAlign(types.AlBottom) 42 | f.Btn1.SetCaption("About") 43 | f.Btn1.SetLeft(10) 44 | f.Btn1.SetTop(10) 45 | f.Btn1.SetOnClick(f.OnBtn1Click) 46 | 47 | f.Lbl = lcl.NewLabel(f) 48 | f.Lbl.SetParent(f) 49 | f.Lbl.SetAlign(types.AlBottom) 50 | f.Lbl.SetCaption("Hello World!") 51 | f.Lbl.SetTop(0) 52 | style := f.Lbl.Font().Style() 53 | f.Lbl.Font().SetStyle(style.Include(types.FsBold, types.FsItalic)) 54 | 55 | f.Edt = lcl.NewSynEdit(f) 56 | f.Edt.SetParent(f) 57 | f.Edt.SetAlign(types.AlClient) 58 | } 59 | 60 | func (f *TMainForm) OnBtn1Click(_ lcl.IObject) { 61 | AboutForm.ShowModal() 62 | } 63 | 64 | func (f *TAboutForm) OnFormCreate(_ lcl.IObject) { 65 | f.SetCaption("About") 66 | f.SetPosition(types.PoMainFormCenter) 67 | f.SetWidth(300) 68 | f.SetHeight(200) 69 | f.SetBorderStyle(types.BsDialog) 70 | // f.SetBorderIcons(types.BiSystemMenu) 71 | 72 | f.Btn1 = lcl.NewButton(f) 73 | f.Btn1.SetParent(f) 74 | f.Btn1.SetCaption("OK") 75 | f.Btn1.SetLeft(10) 76 | f.Btn1.SetTop(10) 77 | f.Btn1.SetOnClick(f.OnBtn1Click) 78 | } 79 | 80 | func (f *TAboutForm) OnBtn1Click(_ lcl.IObject) { 81 | f.Close() 82 | } 83 | -------------------------------------------------------------------------------- /lcl/canvasdef.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | package lcl 10 | 11 | import ( 12 | . "github.com/rarnu/golcl/lcl/api" 13 | . "github.com/rarnu/golcl/lcl/types" 14 | ) 15 | 16 | // 画刷复制 17 | func (c *TCanvas) BrushCopy(dest TRect, bitmap IObject, source TRect, color TColor) { 18 | Canvas_BrushCopy(c.instance, dest, CheckPtr(bitmap), source, color) 19 | } 20 | 21 | // 复制矩形 22 | func (c *TCanvas) CopyRect(dest TRect, canvas IObject, source TRect) { 23 | Canvas_CopyRect(c.instance, dest, CheckPtr(canvas), source) 24 | } 25 | 26 | // 绘制graphic对象 27 | func (c *TCanvas) Draw(x, y int32, graphic IGraphic) { 28 | Canvas_Draw1(c.instance, x, y, CheckPtr(graphic)) 29 | } 30 | 31 | // 绘制graphic对象,opacity透明度 32 | func (c *TCanvas) Draw2(x, y int32, graphic IGraphic, opacity uint8) { 33 | Canvas_Draw2(c.instance, x, y, CheckPtr(graphic), opacity) 34 | } 35 | 36 | // 画焦点矩形 37 | func (c *TCanvas) DrawFocusRect(aRect TRect) { 38 | Canvas_DrawFocusRect(c.instance, aRect) 39 | } 40 | 41 | // 填充矩形 42 | func (c *TCanvas) FillRect(aRect TRect) { 43 | Canvas_FillRect(c.instance, aRect) 44 | } 45 | 46 | // 绘制边框 47 | func (c *TCanvas) FrameRect(aRect TRect) { 48 | Canvas_FrameRect(c.instance, aRect) 49 | } 50 | 51 | // 在矩形内绘制文字 52 | func (c *TCanvas) TextRect(aRect TRect, x, y int32, text string) { 53 | Canvas_TextRect1(c.instance, aRect, x, y, text) 54 | } 55 | 56 | // 在矩形内绘制文字 57 | func (c *TCanvas) TextRect2(aRect *TRect, text string, textFormat TTextFormat) { 58 | Canvas_TextRect2(c.instance, aRect, text, textFormat) 59 | } 60 | 61 | // 填充多边形 62 | func (c *TCanvas) Polygon(points []TPoint) { 63 | Canvas_Polygon(c.instance, points) 64 | } 65 | 66 | // 画多边形,不填充 67 | func (c *TCanvas) Polyline(points []TPoint) { 68 | Canvas_Polyline(c.instance, points) 69 | } 70 | 71 | // 多边形贝塞尔曲线 72 | func (c *TCanvas) PolyBezier(points []TPoint) { 73 | Canvas_PolyBezier(c.instance, points) 74 | } 75 | -------------------------------------------------------------------------------- /lcl/rtl/version/osversion_darwin.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | // 移植来自Delphi 10 | 11 | package version 12 | 13 | import ( 14 | "encoding/xml" 15 | "fmt" 16 | "strconv" 17 | "strings" 18 | 19 | "io/ioutil" 20 | ) 21 | 22 | const ( 23 | sVersionStr = "%s (Version %d.%d.%d)" 24 | //sCName = "hw.optional.x86_64" 25 | pListName = "/System/Library/CoreServices/SystemVersion.plist" 26 | pListServerName = "/System/Library/CoreServices/ServerVersion.plist" 27 | ) 28 | 29 | type cFDataRef struct { 30 | XMLName xml.Name `xml:"plist"` 31 | Dict struct { 32 | XMLName xml.Name `xml:"dict"` 33 | Key []string `xml:"key"` 34 | String []string `xml:"string"` 35 | } 36 | } 37 | 38 | func openDataFromURL(listName string) (bool, []byte) { 39 | bs, err := ioutil.ReadFile(listName) 40 | if err != nil { 41 | return false, nil 42 | } 43 | return true, bs 44 | } 45 | 46 | func initOSVersion() { 47 | OSVersion.Platform = PfMacOS 48 | OSVersion.Name = "Mac OS X" 49 | 50 | validData, lData := openDataFromURL(pListServerName) 51 | if !validData { 52 | validData, lData = openDataFromURL(pListName) 53 | } 54 | if validData { 55 | lDataRef := cFDataRef{} 56 | if err := xml.Unmarshal(lData, &lDataRef); err == nil { 57 | for i, key := range lDataRef.Dict.Key { 58 | if key == "ProductName" { 59 | OSVersion.Name = lDataRef.Dict.String[i] 60 | } 61 | if key == "ProductVersion" { 62 | items := strings.Split(lDataRef.Dict.String[i], ".") 63 | if len(items) > 0 { 64 | OSVersion.Major, _ = strconv.Atoi(items[0]) 65 | } 66 | if len(items) > 1 { 67 | OSVersion.Minor, _ = strconv.Atoi(items[1]) 68 | } 69 | if len(items) > 2 { 70 | OSVersion.ServicePackMajor, _ = strconv.Atoi(items[2]) 71 | } 72 | break 73 | } 74 | } 75 | } 76 | } 77 | OSVersion.fmtVerString = fmt.Sprintf(sVersionStr, OSVersion.Name, OSVersion.Major, OSVersion.Minor, OSVersion.ServicePackMajor) 78 | } 79 | -------------------------------------------------------------------------------- /lcl/api/importFuncsSynPhpSyn.go: -------------------------------------------------------------------------------- 1 | package api 2 | 3 | import ( 4 | . "github.com/rarnu/golcl/lcl/types" 5 | ) 6 | 7 | func SynPHPSyn_Create(owner uintptr) uintptr { 8 | r, _, _ := getLazyProc("SynPHPSyn_Create").Call(owner) 9 | return r 10 | } 11 | 12 | func SynPHPSyn_Free(obj uintptr) { 13 | _, _, _ = getLazyProc("SynPHPSyn_Free").Call(obj) 14 | } 15 | 16 | func SynPHPSyn_StaticClassType() TClass { 17 | r, _, _ := getLazyProc("SynPHPSyn_StaticClassType").Call() 18 | return TClass(r) 19 | } 20 | 21 | func SynPHPSyn_GetEnabled(obj uintptr) bool { 22 | r, _, _ := getLazyProc("SynPHPSyn_GetEnabled").Call(obj) 23 | return DBoolToGoBool(r) 24 | } 25 | 26 | func SynPHPSyn_SetEnabled(obj uintptr, value bool) { 27 | _, _, _ = getLazyProc("SynPHPSyn_SetEnabled").Call(obj, GoBoolToDBool(value)) 28 | } 29 | 30 | func SynPHPSyn_GetCommentAttri(obj uintptr) uintptr { 31 | r, _, _ := getLazyProc("SynPHPSyn_GetCommentAttri").Call(obj) 32 | return r 33 | } 34 | 35 | func SynPHPSyn_GetIdentifierAttri(obj uintptr) uintptr { 36 | r, _, _ := getLazyProc("SynPHPSyn_GetIdentifierAttri").Call(obj) 37 | return r 38 | } 39 | 40 | func SynPHPSyn_GetInvalidSymbolAttri(obj uintptr) uintptr { 41 | r, _, _ := getLazyProc("SynPHPSyn_GetInvalidSymbolAttri").Call(obj) 42 | return r 43 | } 44 | 45 | func SynPHPSyn_GetKeyAttri(obj uintptr) uintptr { 46 | r, _, _ := getLazyProc("SynPHPSyn_GetKeyAttri").Call(obj) 47 | return r 48 | } 49 | 50 | func SynPHPSyn_GetNumberAttri(obj uintptr) uintptr { 51 | r, _, _ := getLazyProc("SynPHPSyn_GetNumberAttri").Call(obj) 52 | return r 53 | } 54 | 55 | func SynPHPSyn_GetSpaceAttri(obj uintptr) uintptr { 56 | r, _, _ := getLazyProc("SynPHPSyn_GetSpaceAttri").Call(obj) 57 | return r 58 | } 59 | 60 | func SynPHPSyn_GetStringAttri(obj uintptr) uintptr { 61 | r, _, _ := getLazyProc("SynPHPSyn_GetStringAttri").Call(obj) 62 | return r 63 | } 64 | 65 | func SynPHPSyn_GetSymbolAttri(obj uintptr) uintptr { 66 | r, _, _ := getLazyProc("SynPHPSyn_GetSymbolAttri").Call(obj) 67 | return r 68 | } 69 | 70 | func SynPHPSyn_GetVariableAttri(obj uintptr) uintptr { 71 | r, _, _ := getLazyProc("SynPHPSyn_GetVariableAttri").Call(obj) 72 | return r 73 | } 74 | -------------------------------------------------------------------------------- /lcl/api/importFuncsSynCssSyn.go: -------------------------------------------------------------------------------- 1 | package api 2 | 3 | import ( 4 | . "github.com/rarnu/golcl/lcl/types" 5 | ) 6 | 7 | func SynCssSyn_Create(owner uintptr) uintptr { 8 | r, _, _ := getLazyProc("SynCssSyn_Create").Call(owner) 9 | return r 10 | } 11 | 12 | func SynCssSyn_Free(obj uintptr) { 13 | _, _, _ = getLazyProc("SynCssSyn_Free").Call(obj) 14 | } 15 | 16 | func SynCssSyn_StaticClassType() TClass { 17 | r, _, _ := getLazyProc("SynCssSyn_StaticClassType").Call() 18 | return TClass(r) 19 | } 20 | 21 | func SynCssSyn_GetEnabled(obj uintptr) bool { 22 | r, _, _ := getLazyProc("SynCssSyn_GetEnabled").Call(obj) 23 | return DBoolToGoBool(r) 24 | } 25 | 26 | func SynCssSyn_SetEnabled(obj uintptr, value bool) { 27 | _, _, _ = getLazyProc("SynCssSyn_SetEnabled").Call(obj, GoBoolToDBool(value)) 28 | } 29 | 30 | func SynCssSyn_GetCommentAttri(obj uintptr) uintptr { 31 | r, _, _ := getLazyProc("SynCssSyn_GetCommentAttri").Call(obj) 32 | return r 33 | } 34 | 35 | func SynCssSyn_GetIdentifierAttri(obj uintptr) uintptr { 36 | r, _, _ := getLazyProc("SynCssSyn_GetIdentifierAttri").Call(obj) 37 | return r 38 | } 39 | 40 | func SynCssSyn_GetKeyAttri(obj uintptr) uintptr { 41 | r, _, _ := getLazyProc("SynCssSyn_GetKeyAttri").Call(obj) 42 | return r 43 | } 44 | 45 | func SynCssSyn_GetNumberAttri(obj uintptr) uintptr { 46 | r, _, _ := getLazyProc("SynCssSyn_GetNumberAttri").Call(obj) 47 | return r 48 | } 49 | 50 | func SynCssSyn_GetSpaceAttri(obj uintptr) uintptr { 51 | r, _, _ := getLazyProc("SynCssSyn_GetSpaceAttri").Call(obj) 52 | return r 53 | } 54 | 55 | func SynCssSyn_GetStringAttri(obj uintptr) uintptr { 56 | r, _, _ := getLazyProc("SynCssSyn_GetStringAttri").Call(obj) 57 | return r 58 | } 59 | 60 | func SynCssSyn_GetSymbolAttri(obj uintptr) uintptr { 61 | r, _, _ := getLazyProc("SynCssSyn_GetSymbolAttri").Call(obj) 62 | return r 63 | } 64 | 65 | func SynCssSyn_GetMeasurementUnitAttri(obj uintptr) uintptr { 66 | r, _, _ := getLazyProc("SynCssSyn_GetMeasurementUnitAttri").Call(obj) 67 | return r 68 | } 69 | 70 | func SynCssSyn_GetSelectorAttri(obj uintptr) uintptr { 71 | r, _, _ := getLazyProc("SynCssSyn_GetSelectorAttri").Call(obj) 72 | return r 73 | } 74 | -------------------------------------------------------------------------------- /lcl/api/intf_posix.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | //go:build !windows 10 | 11 | package api 12 | 13 | import ( 14 | . "github.com/rarnu/golcl/lcl/types" 15 | "unsafe" 16 | ) 17 | 18 | var ( 19 | dSendMessage = liblcl.NewProc("DSendMessage") 20 | dPostMessage = liblcl.NewProc("DPostMessage") 21 | dIsIconic = liblcl.NewProc("DIsIconic") 22 | dIsWindow = liblcl.NewProc("DIsWindow") 23 | dIsZoomed = liblcl.NewProc("DIsZoomed") 24 | dIsWindowVisible = liblcl.NewProc("DIsWindowVisible") 25 | dGetDC = liblcl.NewProc("DGetDC") 26 | dReleaseDC = liblcl.NewProc("DReleaseDC") 27 | dSetForegroundWindow = liblcl.NewProc("DSetForegroundWindow") 28 | dWindowFromPoint = liblcl.NewProc("DWindowFromPoint") 29 | ) 30 | 31 | func DSendMessage(hWd HWND, msg uint32, wParam, lParam uintptr) uintptr { 32 | r, _, _ := dSendMessage.Call(hWd, uintptr(msg), wParam, lParam) 33 | return r 34 | } 35 | 36 | func DPostMessage(hWd HWND, msg uint32, wParam, lParam uintptr) bool { 37 | r, _, _ := dPostMessage.Call(hWd, uintptr(msg), wParam, lParam) 38 | return r != 0 39 | } 40 | 41 | func DIsIconic(hWnd HWND) bool { 42 | r, _, _ := dIsIconic.Call(hWnd) 43 | return r != 0 44 | } 45 | 46 | func DIsWindow(hWnd HWND) bool { 47 | r, _, _ := dIsWindow.Call(hWnd) 48 | return r != 0 49 | } 50 | 51 | func DIsZoomed(hWnd HWND) bool { 52 | r, _, _ := dIsZoomed.Call(hWnd) 53 | return r != 0 54 | } 55 | 56 | func DIsWindowVisible(hWnd HWND) bool { 57 | r, _, _ := dIsWindowVisible.Call(hWnd) 58 | return r != 0 59 | } 60 | 61 | func DGetDC(hWnd HWND) HDC { 62 | r, _, _ := dGetDC.Call(hWnd) 63 | return r 64 | } 65 | 66 | func DReleaseDC(hWnd HWND, dc HDC) int { 67 | r, _, _ := dReleaseDC.Call(hWnd, dc) 68 | return int(r) 69 | } 70 | 71 | func DSetForegroundWindow(hWnd HWND) bool { 72 | r, _, _ := dSetForegroundWindow.Call(hWnd) 73 | return r != 0 74 | } 75 | 76 | func DWindowFromPoint(point TPoint) HWND { 77 | r, _, _ := dWindowFromPoint.Call(uintptr(unsafe.Pointer(&point))) 78 | return r 79 | } 80 | -------------------------------------------------------------------------------- /lcl/init.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | package lcl 10 | 11 | import ( 12 | "fmt" 13 | "os" 14 | "runtime" 15 | 16 | . "github.com/rarnu/golcl/lcl/api" 17 | ) 18 | 19 | const ( 20 | // CN: 要求最小liblcl二进制版本 21 | // EN: Requires a minimum liblcl binary version. 22 | requireMinBinaryVersion = 0x02020000 23 | ) 24 | 25 | var ( 26 | // 几个实例类,不需要Create即可访问,同时也不需要手动Free 27 | 28 | Application *TApplication // 应用程序管理 29 | Screen *TScreen // 屏幕 30 | Mouse *TMouse // 鼠标 31 | Clipboard *TClipboard // 剪切板 32 | Printer *TPrinter // 打印机 33 | ) 34 | 35 | func toVersionString(ver uint32) string { 36 | if byte(ver) == 0 { 37 | return fmt.Sprintf("%d.%d.%d", byte(ver>>24), byte(ver>>16), byte(ver>>8)) 38 | } 39 | return fmt.Sprintf("%d.%d.%d.%d", byte(ver>>24), byte(ver>>16), byte(ver>>8), byte(ver)) 40 | } 41 | 42 | func init() { 43 | if !DEBUG { 44 | defer func() { 45 | if err := recover(); err != nil { 46 | showError(err) 47 | os.Exit(1) 48 | } 49 | }() 50 | } 51 | libVersion := DLibVersion() 52 | fmt.Println("Library Version:", toVersionString(libVersion)) 53 | if libVersion < requireMinBinaryVersion { 54 | panic(fmt.Sprintf("Require liblcl binary version >=%s. Please go to \"https://github.com/rarnu/golcl-liblcl/releases/\" to download the latest binary.", toVersionString(requireMinBinaryVersion))) 55 | } 56 | // 这个似乎得默认加上,锁定主线程,防止中间被改变 57 | runtime.LockOSThread() 58 | // 设置事件的回调函数,因go中callback数量有限,只好折中处理 59 | SetEventCallback(eventCallback) 60 | // 消息回调 61 | SetMessageCallback(messageCallback) 62 | // 线程同步回调 63 | SetThreadSyncCallback(threadSyncCallback) 64 | // 调求回调CreateParams方法 65 | SetRequestCallCreateParamsCallback(requestCallCreateParamsCallback) 66 | 67 | // 导入几个实例类 68 | Application = AsApplication(Application_Instance()) 69 | Screen = AsScreen(Screen_Instance()) 70 | Mouse = AsMouse(Mouse_Instance()) 71 | Clipboard = AsClipboard(Clipboard_Instance()) 72 | Printer = AsPrinter(Printer_Instance()) 73 | 74 | // 尝试加载ICON,仅Windows下有效,尝试加载名为MAINICON的图标 75 | tryLoadAppIcon() 76 | } 77 | -------------------------------------------------------------------------------- /lcl/api/importFuncsSynCppSyn.go: -------------------------------------------------------------------------------- 1 | package api 2 | 3 | import ( 4 | . "github.com/rarnu/golcl/lcl/types" 5 | ) 6 | 7 | func SynCppSyn_Create(owner uintptr) uintptr { 8 | r, _, _ := getLazyProc("SynCppSyn_Create").Call(owner) 9 | return r 10 | } 11 | 12 | func SynCppSyn_Free(obj uintptr) { 13 | _, _, _ = getLazyProc("SynCppSyn_Free").Call(obj) 14 | } 15 | 16 | func SynCppSyn_StaticClassType() TClass { 17 | r, _, _ := getLazyProc("SynCppSyn_StaticClassType").Call() 18 | return TClass(r) 19 | } 20 | 21 | func SynCppSyn_GetEnabled(obj uintptr) bool { 22 | r, _, _ := getLazyProc("SynCppSyn_GetEnabled").Call(obj) 23 | return DBoolToGoBool(r) 24 | } 25 | 26 | func SynCppSyn_SetEnabled(obj uintptr, value bool) { 27 | _, _, _ = getLazyProc("SynCppSyn_SetEnabled").Call(obj, GoBoolToDBool(value)) 28 | } 29 | 30 | func SynCppSyn_GetAsmAttri(obj uintptr) uintptr { 31 | r, _, _ := getLazyProc("SynCppSyn_GetAsmAttri").Call(obj) 32 | return r 33 | } 34 | 35 | func SynCppSyn_GetCommentAttri(obj uintptr) uintptr { 36 | r, _, _ := getLazyProc("SynCppSyn_GetCommentAttri").Call(obj) 37 | return r 38 | } 39 | 40 | func SynCppSyn_GetDirecAttri(obj uintptr) uintptr { 41 | r, _, _ := getLazyProc("SynCppSyn_GetDirecAttri").Call(obj) 42 | return r 43 | } 44 | 45 | func SynCppSyn_GetIdentifierAttri(obj uintptr) uintptr { 46 | r, _, _ := getLazyProc("SynCppSyn_GetIdentifierAttri").Call(obj) 47 | return r 48 | } 49 | 50 | func SynCppSyn_GetInvalidAttri(obj uintptr) uintptr { 51 | r, _, _ := getLazyProc("SynCppSyn_GetInvalidAttri").Call(obj) 52 | return r 53 | } 54 | 55 | func SynCppSyn_GetKeyAttri(obj uintptr) uintptr { 56 | r, _, _ := getLazyProc("SynCppSyn_GetKeyAttri").Call(obj) 57 | return r 58 | } 59 | 60 | func SynCppSyn_GetNumberAttri(obj uintptr) uintptr { 61 | r, _, _ := getLazyProc("SynCppSyn_GetNumberAttri").Call(obj) 62 | return r 63 | } 64 | 65 | func SynCppSyn_GetSpaceAttri(obj uintptr) uintptr { 66 | r, _, _ := getLazyProc("SynCppSyn_GetSpaceAttri").Call(obj) 67 | return r 68 | } 69 | 70 | func SynCppSyn_GetStringAttri(obj uintptr) uintptr { 71 | r, _, _ := getLazyProc("SynCppSyn_GetStringAttri").Call(obj) 72 | return r 73 | } 74 | 75 | func SynCppSyn_GetSymbolAttri(obj uintptr) uintptr { 76 | r, _, _ := getLazyProc("SynCppSyn_GetSymbolAttri").Call(obj) 77 | return r 78 | } 79 | -------------------------------------------------------------------------------- /lcl/platform_darwin.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | //go:build darwin 10 | 11 | package lcl 12 | 13 | /* 14 | 15 | #cgo CFLAGS: -x objective-c 16 | #cgo LDFLAGS: -framework Cocoa 17 | 18 | #include 19 | 20 | static NSWindow* toNSWindow(void* ptr) { 21 | return ((__bridge NSWindow*)ptr); // 22 | } 23 | 24 | // test 25 | static void NSWindow_setTitleVisibility(void *ptr) { 26 | NSWindow *win = toNSWindow(ptr); 27 | win.TitleVisibility = NSWindowTitleHidden; 28 | } 29 | 30 | */ 31 | //import "C" 32 | 33 | import ( 34 | . "github.com/rarnu/golcl/lcl/api" 35 | . "github.com/rarnu/golcl/lcl/types" 36 | ) 37 | 38 | type ( 39 | NSObject uintptr 40 | 41 | NSWindow uintptr 42 | 43 | NSURL uintptr 44 | ) 45 | 46 | // NSObject 47 | func HandleToPlatformHandle(h HWND) NSObject { 48 | return NSObject(h) 49 | } 50 | 51 | func (f *TForm) PlatformWindow() NSWindow { 52 | r, _, _ := NSWindow_FromForm.Call(f.instance) 53 | return NSWindow(r) 54 | } 55 | 56 | func (n NSWindow) TitleVisibility() NSWindowTitleVisibility { 57 | r, _, _ := NSWindow_titleVisibility.Call(uintptr(n)) 58 | return NSWindowTitleVisibility(r) 59 | } 60 | 61 | func (n NSWindow) SetTitleVisibility(flag NSWindowTitleVisibility) { 62 | //C.NSWindow_setTitleVisibility(unsafe.Pointer(n)) 63 | _, _, _ = NSWindow_setTitleVisibility.Call(uintptr(n), uintptr(flag)) 64 | } 65 | 66 | func (n NSWindow) TitleBarAppearsTransparent() bool { 67 | r, _, _ := NSWindow_titlebarAppearsTransparent.Call(uintptr(n)) 68 | return DBoolToGoBool(r) 69 | } 70 | 71 | func (n NSWindow) SetTitleBarAppearsTransparent(flag bool) { 72 | _, _, _ = NSWindow_setTitlebarAppearsTransparent.Call(uintptr(n), GoBoolToDBool(flag)) 73 | } 74 | 75 | func (n NSWindow) SetRepresentedURL(url NSURL) { 76 | _, _, _ = NSWindow_setRepresentedURL.Call(uintptr(n), uintptr(url)) 77 | } 78 | 79 | func (n NSWindow) StyleMask() uint { 80 | r, _, _ := NSWindow_styleMask.Call(uintptr(n)) 81 | return uint(r) 82 | } 83 | 84 | func (n NSWindow) SetStyleMask(mask uint) { 85 | _, _, _ = NSWindow_setStyleMask.Call(uintptr(n), uintptr(mask)) 86 | } 87 | -------------------------------------------------------------------------------- /lcl/api/importFuncsSynJavaSyn.go: -------------------------------------------------------------------------------- 1 | package api 2 | 3 | import ( 4 | . "github.com/rarnu/golcl/lcl/types" 5 | ) 6 | 7 | func SynJavaSyn_Create(owner uintptr) uintptr { 8 | r, _, _ := getLazyProc("SynJavaSyn_Create").Call(owner) 9 | return r 10 | } 11 | 12 | func SynJavaSyn_Free(obj uintptr) { 13 | _, _, _ = getLazyProc("SynJavaSyn_Free").Call(obj) 14 | } 15 | 16 | func SynJavaSyn_StaticClassType() TClass { 17 | r, _, _ := getLazyProc("SynJavaSyn_StaticClassType").Call() 18 | return TClass(r) 19 | } 20 | 21 | func SynJavaSyn_GetEnabled(obj uintptr) bool { 22 | r, _, _ := getLazyProc("SynJavaSyn_GetEnabled").Call(obj) 23 | return DBoolToGoBool(r) 24 | } 25 | 26 | func SynJavaSyn_SetEnabled(obj uintptr, value bool) { 27 | _, _, _ = getLazyProc("SynJavaSyn_SetEnabled").Call(obj, GoBoolToDBool(value)) 28 | } 29 | 30 | func SynJavaSyn_GetAnnotationAttri(obj uintptr) uintptr { 31 | r, _, _ := getLazyProc("SynJavaSyn_GetAnnotationAttri").Call(obj) 32 | return r 33 | } 34 | 35 | func SynJavaSyn_GetCommentAttri(obj uintptr) uintptr { 36 | r, _, _ := getLazyProc("SynJavaSyn_GetCommentAttri").Call(obj) 37 | return r 38 | } 39 | 40 | func SynJavaSyn_GetDocumentAttri(obj uintptr) uintptr { 41 | r, _, _ := getLazyProc("SynJavaSyn_GetDocumentAttri").Call(obj) 42 | return r 43 | } 44 | 45 | func SynJavaSyn_GetIdentifierAttri(obj uintptr) uintptr { 46 | r, _, _ := getLazyProc("SynJavaSyn_GetIdentifierAttri").Call(obj) 47 | return r 48 | } 49 | 50 | func SynJavaSyn_GetInvalidAttri(obj uintptr) uintptr { 51 | r, _, _ := getLazyProc("SynJavaSyn_GetInvalidAttri").Call(obj) 52 | return r 53 | } 54 | 55 | func SynJavaSyn_GetKeyAttri(obj uintptr) uintptr { 56 | r, _, _ := getLazyProc("SynJavaSyn_GetKeyAttri").Call(obj) 57 | return r 58 | } 59 | 60 | func SynJavaSyn_GetNumberAttri(obj uintptr) uintptr { 61 | r, _, _ := getLazyProc("SynJavaSyn_GetNumberAttri").Call(obj) 62 | return r 63 | } 64 | 65 | func SynJavaSyn_GetSpaceAttri(obj uintptr) uintptr { 66 | r, _, _ := getLazyProc("SynJavaSyn_GetSpaceAttri").Call(obj) 67 | return r 68 | } 69 | 70 | func SynJavaSyn_GetStringAttri(obj uintptr) uintptr { 71 | r, _, _ := getLazyProc("SynJavaSyn_GetStringAttri").Call(obj) 72 | return r 73 | } 74 | 75 | func SynJavaSyn_GetSymbolAttri(obj uintptr) uintptr { 76 | r, _, _ := getLazyProc("SynJavaSyn_GetSymbolAttri").Call(obj) 77 | return r 78 | } 79 | -------------------------------------------------------------------------------- /lcl/api/importFuncsChartShadow.go: -------------------------------------------------------------------------------- 1 | package api 2 | 3 | import ( 4 | . "github.com/rarnu/golcl/lcl/types" 5 | ) 6 | 7 | func ChartShadow_Create(obj uintptr) uintptr { 8 | ret, _, _ := getLazyProc("ChartShadow_Create").Call(obj) 9 | return ret 10 | } 11 | 12 | func ChartShadow_Free(obj uintptr) { 13 | _, _, _ = getLazyProc("ChartShadow_Free").Call(obj) 14 | } 15 | 16 | func ChartShadow_StaticClassType() TClass { 17 | ret, _, _ := getLazyProc("ChartShadow_StaticClassType").Call() 18 | return TClass(ret) 19 | } 20 | 21 | func ChartShadow_GetColor(obj uintptr) TColor { 22 | ret, _, _ := getLazyProc("ChartShadow_GetColor").Call(obj) 23 | return TColor(ret) 24 | } 25 | 26 | func ChartShadow_SetColor(obj uintptr, value TColor) { 27 | _, _, _ = getLazyProc("ChartShadow_SetColor").Call(obj, uintptr(value)) 28 | } 29 | 30 | func ChartShadow_GetOffsetX(obj uintptr) int32 { 31 | ret, _, _ := getLazyProc("ChartShadow_GetOffsetX").Call(obj) 32 | return int32(ret) 33 | } 34 | 35 | func ChartShadow_SetOffsetX(obj uintptr, value int32) { 36 | _, _, _ = getLazyProc("ChartShadow_SetOffsetX").Call(obj, uintptr(value)) 37 | } 38 | 39 | func ChartShadow_GetOffsetY(obj uintptr) int32 { 40 | ret, _, _ := getLazyProc("ChartShadow_GetOffsetY").Call(obj) 41 | return int32(ret) 42 | } 43 | 44 | func ChartShadow_SetOffsetY(obj uintptr, value int32) { 45 | _, _, _ = getLazyProc("ChartShadow_SetOffsetY").Call(obj, uintptr(value)) 46 | } 47 | 48 | func ChartShadow_GetTransparency(obj uintptr) TChartTransparency { 49 | ret, _, _ := getLazyProc("ChartShadow_GetTransparency").Call(obj) 50 | return TChartTransparency(ret) 51 | } 52 | 53 | func ChartShadow_SetTransparency(obj uintptr, value TChartTransparency) { 54 | _, _, _ = getLazyProc("ChartShadow_SetTransparency").Call(obj, uintptr(value)) 55 | } 56 | 57 | func ChartShadow_GetVisible(obj uintptr) bool { 58 | ret, _, _ := getLazyProc("ChartShadow_GetVisible").Call(obj) 59 | return DBoolToGoBool(ret) 60 | } 61 | 62 | func ChartShadow_SetVisible(obj uintptr, value bool) { 63 | _, _, _ = getLazyProc("ChartShadow_SetVisible").Call(obj, GoBoolToDBool(value)) 64 | } 65 | 66 | func ChartShadow_GetOwner(obj uintptr) uintptr { 67 | ret, _, _ := getLazyProc("ChartShadow_GetOwner").Call(obj) 68 | return ret 69 | } 70 | 71 | func ChartShadow_SetOwner(obj uintptr, AOwner uintptr) { 72 | _, _, _ = getLazyProc("ChartShadow_SetOwner").Call(obj, AOwner) 73 | } 74 | -------------------------------------------------------------------------------- /lcl/api/importFuncsSynJScriptSyn.go: -------------------------------------------------------------------------------- 1 | package api 2 | 3 | import ( 4 | . "github.com/rarnu/golcl/lcl/types" 5 | ) 6 | 7 | func SynJScriptSyn_Create(owner uintptr) uintptr { 8 | r, _, _ := getLazyProc("SynJScriptSyn_Create").Call(owner) 9 | return r 10 | } 11 | 12 | func SynJScriptSyn_Free(obj uintptr) { 13 | _, _, _ = getLazyProc("SynJScriptSyn_Free").Call(obj) 14 | } 15 | 16 | func SynJScriptSyn_StaticClassType() TClass { 17 | r, _, _ := getLazyProc("SynJScriptSyn_StaticClassType").Call() 18 | return TClass(r) 19 | } 20 | 21 | func SynJScriptSyn_GetEnabled(obj uintptr) bool { 22 | r, _, _ := getLazyProc("SynJScriptSyn_GetEnabled").Call(obj) 23 | return DBoolToGoBool(r) 24 | } 25 | 26 | func SynJScriptSyn_SetEnabled(obj uintptr, value bool) { 27 | _, _, _ = getLazyProc("SynJScriptSyn_SetEnabled").Call(obj, GoBoolToDBool(value)) 28 | } 29 | 30 | func SynJScriptSyn_GetBracketAttri(obj uintptr) uintptr { 31 | r, _, _ := getLazyProc("SynJScriptSyn_GetBracketAttri").Call(obj) 32 | return r 33 | } 34 | 35 | func SynJScriptSyn_GetCommentAttri(obj uintptr) uintptr { 36 | r, _, _ := getLazyProc("SynJScriptSyn_GetCommentAttri").Call(obj) 37 | return r 38 | } 39 | 40 | func SynJScriptSyn_GetIdentifierAttri(obj uintptr) uintptr { 41 | r, _, _ := getLazyProc("SynJScriptSyn_GetIdentifierAttri").Call(obj) 42 | return r 43 | } 44 | 45 | func SynJScriptSyn_GetKeyAttri(obj uintptr) uintptr { 46 | r, _, _ := getLazyProc("SynJScriptSyn_GetKeyAttri").Call(obj) 47 | return r 48 | } 49 | 50 | func SynJScriptSyn_GetNonReservedKeyAttri(obj uintptr) uintptr { 51 | r, _, _ := getLazyProc("SynJScriptSyn_GetNonReservedKeyAttri").Call(obj) 52 | return r 53 | } 54 | 55 | func SynJScriptSyn_GetEventAttri(obj uintptr) uintptr { 56 | r, _, _ := getLazyProc("SynJScriptSyn_GetEventAttri").Call(obj) 57 | return r 58 | } 59 | 60 | func SynJScriptSyn_GetNumberAttri(obj uintptr) uintptr { 61 | r, _, _ := getLazyProc("SynJScriptSyn_GetNumberAttri").Call(obj) 62 | return r 63 | } 64 | 65 | func SynJScriptSyn_GetSpaceAttri(obj uintptr) uintptr { 66 | r, _, _ := getLazyProc("SynJScriptSyn_GetSpaceAttri").Call(obj) 67 | return r 68 | } 69 | 70 | func SynJScriptSyn_GetStringAttri(obj uintptr) uintptr { 71 | r, _, _ := getLazyProc("SynJScriptSyn_GetStringAttri").Call(obj) 72 | return r 73 | } 74 | 75 | func SynJScriptSyn_GetSymbolAttri(obj uintptr) uintptr { 76 | r, _, _ := getLazyProc("SynJScriptSyn_GetSymbolAttri").Call(obj) 77 | return r 78 | } 79 | -------------------------------------------------------------------------------- /lcl/callback_posix.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | //go:build !windows && cgo 10 | 11 | package lcl 12 | 13 | //// #cgo darwin CFLAGS: -mmacosx-version-min=10.8 -DMACOSX_DEPLOYMENT_TARGET=10.8 14 | // #cgo darwin CFLAGS: -mmacosx-version-min=10.8 15 | // #cgo darwin LDFLAGS: -mmacosx-version-min=10.8 16 | // 17 | // extern void* doEventCallbackProc(void* f, void* args, long argcount); 18 | // static void* doGetEventCallbackAddr() { 19 | // return &doEventCallbackProc; 20 | // } 21 | // 22 | // extern void* doMessageCallbackProc(void* f, void* msg); 23 | // static void* doGetMessageCallbackAddr() { 24 | // return &doMessageCallbackProc; 25 | // } 26 | // 27 | // extern void* doThreadSyncCallbackProc(); 28 | // static void* doGetThreadSyncCallbackAddr() { 29 | // return &doThreadSyncCallbackProc; 30 | // } 31 | // 32 | // extern void* doRequestCallCreateParamsCallbackProc(void* ptr, void* params); 33 | // static void* doRequestCallCreateParamsCallbackAddr() { 34 | // return &doRequestCallCreateParamsCallbackProc; 35 | // } 36 | import "C" 37 | 38 | import ( 39 | "unsafe" 40 | ) 41 | 42 | //export doEventCallbackProc 43 | func doEventCallbackProc(f unsafe.Pointer, args unsafe.Pointer, argcount C.long) unsafe.Pointer { 44 | eventCallbackProc(uintptr(f), uintptr(args), int(argcount)) 45 | return nullptr 46 | } 47 | 48 | //export doMessageCallbackProc 49 | func doMessageCallbackProc(f unsafe.Pointer, msg unsafe.Pointer) unsafe.Pointer { 50 | messageCallbackProc(uintptr(f), uintptr(msg)) 51 | return nullptr 52 | } 53 | 54 | //export doThreadSyncCallbackProc 55 | func doThreadSyncCallbackProc() unsafe.Pointer { 56 | threadSyncCallbackProc() 57 | return nullptr 58 | } 59 | 60 | //export doRequestCallCreateParamsCallbackProc 61 | func doRequestCallCreateParamsCallbackProc(ptr unsafe.Pointer, params unsafe.Pointer) unsafe.Pointer { 62 | requestCallCreateParamsCallbackProc(uintptr(ptr), uintptr(params)) 63 | return nullptr 64 | } 65 | 66 | var ( 67 | eventCallback = uintptr(C.doGetEventCallbackAddr()) 68 | messageCallback = uintptr(C.doGetMessageCallbackAddr()) 69 | threadSyncCallback = uintptr(C.doGetThreadSyncCallbackAddr()) 70 | requestCallCreateParamsCallback = uintptr(C.doRequestCallCreateParamsCallbackAddr()) 71 | ) 72 | -------------------------------------------------------------------------------- /lcl/api/importFuncsIconOptions.go: -------------------------------------------------------------------------------- 1 | package api 2 | 3 | import ( 4 | . "github.com/rarnu/golcl/lcl/types" 5 | ) 6 | 7 | //--------------------------- TIconOptions --------------------------- 8 | 9 | func IconOptions_Assign(obj uintptr, Source uintptr) { 10 | _, _, _ = getLazyProc("IconOptions_Assign").Call(obj, Source) 11 | } 12 | 13 | func IconOptions_GetNamePath(obj uintptr) string { 14 | ret, _, _ := getLazyProc("IconOptions_GetNamePath").Call(obj) 15 | return DStrToGoStr(ret) 16 | } 17 | 18 | func IconOptions_ClassType(obj uintptr) TClass { 19 | ret, _, _ := getLazyProc("IconOptions_ClassType").Call(obj) 20 | return TClass(ret) 21 | } 22 | 23 | func IconOptions_ClassName(obj uintptr) string { 24 | ret, _, _ := getLazyProc("IconOptions_ClassName").Call(obj) 25 | return DStrToGoStr(ret) 26 | } 27 | 28 | func IconOptions_InstanceSize(obj uintptr) int32 { 29 | ret, _, _ := getLazyProc("IconOptions_InstanceSize").Call(obj) 30 | return int32(ret) 31 | } 32 | 33 | func IconOptions_InheritsFrom(obj uintptr, AClass TClass) bool { 34 | ret, _, _ := getLazyProc("IconOptions_InheritsFrom").Call(obj, uintptr(AClass)) 35 | return DBoolToGoBool(ret) 36 | } 37 | 38 | func IconOptions_Equals(obj uintptr, Obj uintptr) bool { 39 | ret, _, _ := getLazyProc("IconOptions_Equals").Call(obj, Obj) 40 | return DBoolToGoBool(ret) 41 | } 42 | 43 | func IconOptions_GetHashCode(obj uintptr) int32 { 44 | ret, _, _ := getLazyProc("IconOptions_GetHashCode").Call(obj) 45 | return int32(ret) 46 | } 47 | 48 | func IconOptions_ToString(obj uintptr) string { 49 | ret, _, _ := getLazyProc("IconOptions_ToString").Call(obj) 50 | return DStrToGoStr(ret) 51 | } 52 | 53 | func IconOptions_GetArrangement(obj uintptr) TIconArrangement { 54 | ret, _, _ := getLazyProc("IconOptions_GetArrangement").Call(obj) 55 | return TIconArrangement(ret) 56 | } 57 | 58 | func IconOptions_SetArrangement(obj uintptr, value TIconArrangement) { 59 | _, _, _ = getLazyProc("IconOptions_SetArrangement").Call(obj, uintptr(value)) 60 | } 61 | 62 | func IconOptions_GetAutoArrange(obj uintptr) bool { 63 | ret, _, _ := getLazyProc("IconOptions_GetAutoArrange").Call(obj) 64 | return DBoolToGoBool(ret) 65 | } 66 | 67 | func IconOptions_SetAutoArrange(obj uintptr, value bool) { 68 | _, _, _ = getLazyProc("IconOptions_SetAutoArrange").Call(obj, GoBoolToDBool(value)) 69 | } 70 | 71 | func IconOptions_StaticClassType() TClass { 72 | r, _, _ := getLazyProc("IconOptions_StaticClassType").Call() 73 | return TClass(r) 74 | } 75 | -------------------------------------------------------------------------------- /lcl/api/importFuncsMouse.go: -------------------------------------------------------------------------------- 1 | package api 2 | 3 | import ( 4 | . "github.com/rarnu/golcl/lcl/types" 5 | "unsafe" 6 | ) 7 | 8 | //--------------------------- TMouse --------------------------- 9 | 10 | func Mouse_Create() uintptr { 11 | ret, _, _ := getLazyProc("Mouse_Create").Call() 12 | return ret 13 | } 14 | 15 | func Mouse_Free(obj uintptr) { 16 | _, _, _ = getLazyProc("Mouse_Free").Call(obj) 17 | } 18 | 19 | func Mouse_ClassType(obj uintptr) TClass { 20 | ret, _, _ := getLazyProc("Mouse_ClassType").Call(obj) 21 | return TClass(ret) 22 | } 23 | 24 | func Mouse_ClassName(obj uintptr) string { 25 | ret, _, _ := getLazyProc("Mouse_ClassName").Call(obj) 26 | return DStrToGoStr(ret) 27 | } 28 | 29 | func Mouse_InstanceSize(obj uintptr) int32 { 30 | ret, _, _ := getLazyProc("Mouse_InstanceSize").Call(obj) 31 | return int32(ret) 32 | } 33 | 34 | func Mouse_InheritsFrom(obj uintptr, AClass TClass) bool { 35 | ret, _, _ := getLazyProc("Mouse_InheritsFrom").Call(obj, uintptr(AClass)) 36 | return DBoolToGoBool(ret) 37 | } 38 | 39 | func Mouse_Equals(obj uintptr, Obj uintptr) bool { 40 | ret, _, _ := getLazyProc("Mouse_Equals").Call(obj, Obj) 41 | return DBoolToGoBool(ret) 42 | } 43 | 44 | func Mouse_GetHashCode(obj uintptr) int32 { 45 | ret, _, _ := getLazyProc("Mouse_GetHashCode").Call(obj) 46 | return int32(ret) 47 | } 48 | 49 | func Mouse_ToString(obj uintptr) string { 50 | ret, _, _ := getLazyProc("Mouse_ToString").Call(obj) 51 | return DStrToGoStr(ret) 52 | } 53 | 54 | func Mouse_GetCapture(obj uintptr) HWND { 55 | ret, _, _ := getLazyProc("Mouse_GetCapture").Call(obj) 56 | return ret 57 | } 58 | 59 | func Mouse_SetCapture(obj uintptr, value HWND) { 60 | _, _, _ = getLazyProc("Mouse_SetCapture").Call(obj, value) 61 | } 62 | 63 | func Mouse_GetCursorPos(obj uintptr) TPoint { 64 | var ret TPoint 65 | _, _, _ = getLazyProc("Mouse_GetCursorPos").Call(obj, uintptr(unsafe.Pointer(&ret))) 66 | return ret 67 | } 68 | 69 | func Mouse_SetCursorPos(obj uintptr, value TPoint) { 70 | _, _, _ = getLazyProc("Mouse_SetCursorPos").Call(obj, uintptr(unsafe.Pointer(&value))) 71 | } 72 | 73 | func Mouse_GetIsDragging(obj uintptr) bool { 74 | ret, _, _ := getLazyProc("Mouse_GetIsDragging").Call(obj) 75 | return DBoolToGoBool(ret) 76 | } 77 | 78 | func Mouse_GetWheelScrollLines(obj uintptr) int32 { 79 | ret, _, _ := getLazyProc("Mouse_GetWheelScrollLines").Call(obj) 80 | return int32(ret) 81 | } 82 | 83 | func Mouse_StaticClassType() TClass { 84 | r, _, _ := getLazyProc("Mouse_StaticClassType").Call() 85 | return TClass(r) 86 | } 87 | -------------------------------------------------------------------------------- /lcl/api/stdstr.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | package api 10 | 11 | import ( 12 | "unsafe" 13 | ) 14 | 15 | // StringToUTF8Ptr 字符串到UTF8指针 16 | func StringToUTF8Ptr(s string) *uint8 { 17 | temp := []byte(s) 18 | utf8StrArr := make([]uint8, len(temp)+1) // +1是因为Lazarus中PChar为0结尾 19 | copy(utf8StrArr, temp) 20 | return &utf8StrArr[0] 21 | } 22 | 23 | func PascalStr(str string) uintptr { 24 | if str == "" { 25 | return 0 26 | } 27 | return uintptr(unsafe.Pointer(StringToUTF8Ptr(str))) 28 | } 29 | 30 | // GoStrToDStr Go的string转换为Lazarus的string 31 | func GoStrToDStr(s string) uintptr { 32 | if s == "" { 33 | return 0 34 | } 35 | return uintptr(unsafe.Pointer(StringToUTF8Ptr(s))) 36 | } 37 | 38 | // 这种跟copyStr3基本一样,只是用go来处理了 39 | func copyStr(src uintptr, strLen int) string { 40 | if strLen == 0 { 41 | return "" 42 | } 43 | str := make([]uint8, strLen) 44 | for i := 0; i < strLen; i++ { 45 | str[i] = *(*uint8)(unsafe.Pointer(src + uintptr(i))) 46 | } 47 | return string(str) 48 | } 49 | 50 | type GoStringHeader struct { 51 | Data uintptr 52 | Len int 53 | } 54 | 55 | // 小点的字符适合此种方式,大了就不行了 56 | func copyStr2(str uintptr, strLen int) string { 57 | if strLen == 0 { 58 | return "" 59 | } 60 | var ret string 61 | head := (*GoStringHeader)(unsafe.Pointer(&ret)) 62 | head.Data = str 63 | head.Len = strLen 64 | return ret 65 | } 66 | 67 | // 最新的lz macOS下出问题了 68 | func copyStr3(str uintptr, strLen int) string { 69 | if strLen == 0 { 70 | return "" 71 | } 72 | buffer := make([]uint8, strLen) 73 | DMove(str, uintptr(unsafe.Pointer(&buffer[0])), strLen) 74 | return string(buffer) 75 | } 76 | 77 | // DStrToGoStr Lazarus的string转换为Go的string 78 | func DStrToGoStr(ustr uintptr) string { 79 | l := DStrLen(ustr) 80 | if l == 0 { 81 | return "" 82 | } 83 | return copyStr(ustr, l) 84 | } 85 | 86 | func GoStr(str uintptr) string { 87 | l := DStrLen(str) 88 | if l == 0 { 89 | return "" 90 | } 91 | return copyStr(str, int(l)) 92 | } 93 | 94 | func getBuff(size int32) any { 95 | return make([]uint8, size+1) 96 | } 97 | 98 | func getBuffPtr(buff any) uintptr { 99 | return uintptr(unsafe.Pointer(&(buff.([]uint8))[0])) 100 | } 101 | 102 | func getTextBuf(strBuff any, Buffer *string, slen int) { 103 | *Buffer = string((strBuff.([]uint8))[:slen]) 104 | } 105 | -------------------------------------------------------------------------------- /lcl/api/importFuncsSynGutter.go: -------------------------------------------------------------------------------- 1 | package api 2 | 3 | import ( 4 | . "github.com/rarnu/golcl/lcl/types" 5 | ) 6 | 7 | //--------------------------- TSynGutter --------------------------- 8 | 9 | func SynGutter_Free(obj uintptr) { 10 | _, _, _ = getLazyProc("SynGutter_Free").Call(obj) 11 | } 12 | 13 | func SynGutter_ClassName(obj uintptr) string { 14 | r, _, _ := getLazyProc("SynGutter_ClassName").Call(obj) 15 | return DStrToGoStr(r) 16 | } 17 | 18 | func SynGutter_GetHashCode(obj uintptr) int32 { 19 | r, _, _ := getLazyProc("SynGutter_GetHashCode").Call(obj) 20 | return int32(r) 21 | } 22 | 23 | func SynGutter_Equals(obj, obj2 uintptr) bool { 24 | r, _, _ := getLazyProc("SynGutter_Equals").Call(obj, obj2) 25 | return DBoolToGoBool(r) 26 | } 27 | 28 | func SynGutter_ClassType(obj uintptr) TClass { 29 | r, _, _ := getLazyProc("SynGutter_ClassType").Call(obj) 30 | return TClass(r) 31 | } 32 | 33 | func SynGutter_InstanceSize(obj uintptr) int32 { 34 | r, _, _ := getLazyProc("SynGutter_InstanceSize").Call(obj) 35 | return int32(r) 36 | } 37 | 38 | func SynGutter_InheritsFrom(obj uintptr, AClass TClass) bool { 39 | r, _, _ := getLazyProc("SynGutter_InheritsFrom").Call(obj, uintptr(AClass)) 40 | return DBoolToGoBool(r) 41 | } 42 | 43 | func SynGutter_GetAutoSize(obj uintptr) bool { 44 | r, _, _ := getLazyProc("SynGutter_GetAutoSize").Call(obj) 45 | return DBoolToGoBool(r) 46 | } 47 | 48 | func SynGutter_SetAutoSize(obj uintptr, value bool) { 49 | _, _, _ = getLazyProc("SynGutter_SetAutoSize").Call(obj, GoBoolToDBool(value)) 50 | } 51 | 52 | func SynGutter_StaticClassType() TClass { 53 | r, _, _ := getLazyProc("SynGutter_StaticClassType").Call() 54 | return TClass(r) 55 | } 56 | 57 | func SynGutter_GetColor(obj uintptr) TColor { 58 | r, _, _ := getLazyProc("SynGutter_GetColor").Call(obj) 59 | return TColor(r) 60 | } 61 | 62 | func SynGutter_SetColor(obj uintptr, value TColor) { 63 | _, _, _ = getLazyProc("SynGutter_SetColor").Call(obj, uintptr(value)) 64 | } 65 | 66 | func SynGutter_GetVisible(obj uintptr) bool { 67 | r, _, _ := getLazyProc("SynGutter_GetVisible").Call(obj) 68 | return DBoolToGoBool(r) 69 | } 70 | 71 | func SynGutter_SetVisible(obj uintptr, value bool) { 72 | _, _, _ = getLazyProc("SynGutter_SetVisible").Call(obj, GoBoolToDBool(value)) 73 | } 74 | 75 | func SynGutter_GetWidth(obj uintptr) int32 { 76 | r, _, _ := getLazyProc("SynGutter_GetWidth").Call(obj) 77 | return int32(r) 78 | } 79 | 80 | func SynGutter_SetWidth(obj uintptr, value int32) { 81 | _, _, _ = getLazyProc("SynGutter_SetWidth").Call(obj, uintptr(value)) 82 | } 83 | -------------------------------------------------------------------------------- /lcl/win/tlhelp32.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | //go:build windows 10 | 11 | package win 12 | 13 | import "unsafe" 14 | 15 | // The th32ProcessID argument is only used if TH32CS_SNAPHEAPLIST or 16 | // TH32CS_SNAPMODULE is specified. th32ProcessID == 0 means the current 17 | // process. 18 | // 19 | // NOTE that all of the snapshots are global except for the heap and module 20 | // lists which are process specific. To enumerate the heap or module 21 | // state for all WIN32 processes call with TH32CS_SNAPALL and the 22 | // current process. Then for each process in the TH32CS_SNAPPROCESS 23 | // list that isn't the current process, do a call with just 24 | // TH32CS_SNAPHEAPLIST and/or TH32CS_SNAPMODULE. 25 | // 26 | // dwFlags 27 | // 28 | const ( 29 | TH32CS_SNAPHEAPLIST = 0x00000001 30 | TH32CS_SNAPPROCESS = 0x00000002 31 | TH32CS_SNAPTHREAD = 0x00000004 32 | TH32CS_SNAPMODULE = 0x00000008 33 | TH32CS_SNAPALL = TH32CS_SNAPHEAPLIST | TH32CS_SNAPPROCESS | TH32CS_SNAPTHREAD | TH32CS_SNAPMODULE 34 | TH32CS_INHERIT = 0x80000000 35 | ) 36 | 37 | type TProcessEntry32 struct { 38 | DwSize uint32 39 | CntUsage uint32 40 | Th32ProcessID uint32 // this process 41 | Th2DefaultHeapID uintptr 42 | Th32ModuleID uint32 // associated exe 43 | CntThreads uint32 44 | Th32ParentProcessID uint32 // this process's parent process 45 | PcPriClassBase uint32 // Base priority of process's threads 46 | DwFlags uint32 47 | SzExeFile [MAX_PATH]uint16 // Path 48 | 49 | } 50 | 51 | var ( 52 | _CreateToolhelp32Snapshot = kernel32dll.NewProc("CreateToolhelp32Snapshot") 53 | _Process32First = kernel32dll.NewProc("Process32FirstW") 54 | _Process32Next = kernel32dll.NewProc("Process32NextW") 55 | ) 56 | 57 | // CreateToolhelp32SnapShot 58 | func CreateToolhelp32SnapShot(dwFlags, th32ProcessID uint32) uintptr { 59 | r, _, _ := _CreateToolhelp32Snapshot.Call(uintptr(dwFlags), uintptr(th32ProcessID)) 60 | return r 61 | } 62 | 63 | // Process32First 64 | func Process32First(hSnapshot uintptr, lppe *TProcessEntry32) bool { 65 | r, _, _ := _Process32First.Call(hSnapshot, uintptr(unsafe.Pointer(lppe))) 66 | return r != 0 67 | } 68 | 69 | // Process32Next 70 | func Process32Next(hSnapshot uintptr, lppe *TProcessEntry32) bool { 71 | r, _, _ := _Process32Next.Call(hSnapshot, uintptr(unsafe.Pointer(lppe))) 72 | return r != 0 73 | } 74 | -------------------------------------------------------------------------------- /lcl/miniwebviewdef.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | //go:build windows 10 | 11 | package lcl 12 | 13 | import ( 14 | "runtime" 15 | "strconv" 16 | "strings" 17 | 18 | "github.com/rarnu/golcl/lcl/rtl" 19 | "github.com/rarnu/golcl/lcl/win" 20 | ) 21 | 22 | // Windows下设置TMiiWebview的IE内核版本,需管理员权限才可以写注册表 23 | // 24 | // Set the IE kernel version of TMiiWebview under Windows, you need administrator privileges. 25 | func (m *TMiniWebview) SetIEVersion(version int) { 26 | 27 | // 7000 Webpages containing standards-based !DOCTYPE directives are displayed in IE7 Standards mode. 28 | // 8000 Webpages containing standards-based !DOCTYPE directives are displayed in IE8 mode. 29 | // 9000 Internet Explorer 9. Webpages containing standards-based !DOCTYPE directives are displayed in IE9 mode. 30 | // 10000 Internet Explorer 10. 31 | // 11000 Internet Explorer 11. Webpages containing standards-based !DOCTYPE directives are displayed in IE11 Standards mode. 32 | // 默认的就是7 33 | // HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION 34 | if version >= 7 && version <= 11 { 35 | var access uint32 = win.KEY_ALL_ACCESS 36 | // 当前是32位的程序运行在x64下面 37 | //if win.IsWow64() { 38 | if runtime.GOARCH == "amd64" { 39 | access |= win.KEY_WOW64_64KEY 40 | } 41 | //} 42 | reg := NewRegistry(access) 43 | defer reg.Free() 44 | reg.SetRootKey(win.HKEY_CURRENT_USER) 45 | if reg.OpenKey("Software\\Microsoft\\Internet Explorer\\Main\\FeatureControl\\FEATURE_BROWSER_EMULATION", false) { 46 | defer reg.CloseKey() 47 | reg.WriteInteger(rtl.ExtractFileName(Application.ExeName()), int32(version*1000)) 48 | } 49 | } 50 | } 51 | 52 | // Windows下读取IE内核版本,需管理员权限才可以写注册表 53 | // 54 | // Read the IE kernel version under Windows, you need administrator rights to write the registry. 55 | func (m *TMiniWebview) GetIEVersion() int { 56 | reg := NewRegistryAllAccess() 57 | defer reg.Free() 58 | reg.SetRootKey(win.HKEY_LOCAL_MACHINE) 59 | if reg.OpenKey("SOFTWARE\\Microsoft\\Internet Explorer", false) { 60 | defer reg.CloseKey() 61 | verStr := "" 62 | if reg.ValueExists("svcVersion") { 63 | verStr = reg.ReadString("svcVersion") 64 | } else if reg.ValueExists("Version") { 65 | verStr = reg.ReadString("Version") 66 | } 67 | if verStr != "" { 68 | vArr := strings.Split(verStr, ".") 69 | if len(vArr) >= 1 { 70 | v, _ := strconv.Atoi(vArr[0]) 71 | return v 72 | } 73 | } 74 | } 75 | return 0 76 | } 77 | -------------------------------------------------------------------------------- /lcl/api/importFuncsChartArrow.go: -------------------------------------------------------------------------------- 1 | package api 2 | 3 | import ( 4 | . "github.com/rarnu/golcl/lcl/types" 5 | "unsafe" 6 | ) 7 | 8 | func ChartArrow_Create(obj uintptr) uintptr { 9 | ret, _, _ := getLazyProc("ChartArrow_Create").Call(obj) 10 | return ret 11 | } 12 | 13 | func ChartArrow_Free(obj uintptr) { 14 | _, _, _ = getLazyProc("ChartArrow_Free").Call(obj) 15 | } 16 | 17 | func ChartArrow_StaticClassType() TClass { 18 | ret, _, _ := getLazyProc("ChartArrow_StaticClassType").Call() 19 | return TClass(ret) 20 | } 21 | 22 | func ChartArrow_GetBaseLength(obj uintptr) TChartDistance { 23 | ret, _, _ := getLazyProc("ChartArrow_GetBaseLength").Call(obj) 24 | return TChartDistance(ret) 25 | } 26 | 27 | func ChartArrow_SetBaseLength(obj uintptr, value TChartDistance) { 28 | _, _, _ = getLazyProc("ChartArrow_SetBaseLength").Call(obj, uintptr(value)) 29 | } 30 | 31 | func ChartArrow_GetInverted(obj uintptr) bool { 32 | ret, _, _ := getLazyProc("ChartArrow_GetInverted").Call(obj) 33 | return DBoolToGoBool(ret) 34 | } 35 | 36 | func ChartArrow_SetInverted(obj uintptr, value bool) { 37 | _, _, _ = getLazyProc("ChartArrow_SetInverted").Call(obj, GoBoolToDBool(value)) 38 | } 39 | 40 | func ChartArrow_GetLength(obj uintptr) TChartDistance { 41 | ret, _, _ := getLazyProc("ChartArrow_GetLength").Call(obj) 42 | return TChartDistance(ret) 43 | } 44 | 45 | func ChartArrow_SetLength(obj uintptr, value TChartDistance) { 46 | _, _, _ = getLazyProc("ChartArrow_SetLength").Call(obj, uintptr(value)) 47 | } 48 | 49 | func ChartArrow_GetWidth(obj uintptr) TChartDistance { 50 | ret, _, _ := getLazyProc("ChartArrow_GetWidth").Call(obj) 51 | return TChartDistance(ret) 52 | } 53 | 54 | func ChartArrow_SetWidth(obj uintptr, value TChartDistance) { 55 | _, _, _ = getLazyProc("ChartArrow_SetWidth").Call(obj, uintptr(value)) 56 | } 57 | 58 | func ChartArrow_GetVisible(obj uintptr) bool { 59 | ret, _, _ := getLazyProc("ChartArrow_GetVisible").Call(obj) 60 | return DBoolToGoBool(ret) 61 | } 62 | 63 | func ChartArrow_SetVisible(obj uintptr, value bool) { 64 | _, _, _ = getLazyProc("ChartArrow_SetVisible").Call(obj, GoBoolToDBool(value)) 65 | } 66 | 67 | func ChartArrow_Draw(obj uintptr, ADrawer uintptr, AEndPos TPoint, AAngle float64, APen uintptr) { 68 | _, _, _ = getLazyProc("ChartArrow_Draw").Call(obj, ADrawer, uintptr(unsafe.Pointer(&AEndPos)), uintptr(unsafe.Pointer(&AAngle)), APen) 69 | } 70 | 71 | func ChartArrow_GetOwner(obj uintptr) uintptr { 72 | ret, _, _ := getLazyProc("ChartArrow_GetOwner").Call(obj) 73 | return ret 74 | } 75 | 76 | func ChartArrow_SetOwner(obj uintptr, AOwner uintptr) { 77 | _, _, _ = getLazyProc("ChartArrow_SetOwner").Call(obj, AOwner) 78 | } 79 | -------------------------------------------------------------------------------- /lcl/api/importFuncsAnchorSide.go: -------------------------------------------------------------------------------- 1 | package api 2 | 3 | import ( 4 | . "github.com/rarnu/golcl/lcl/types" 5 | ) 6 | 7 | //--------------------------- TAnchorSide --------------------------- 8 | 9 | func AnchorSide_Assign(obj uintptr, Source uintptr) { 10 | _, _, _ = getLazyProc("AnchorSide_Assign").Call(obj, Source) 11 | } 12 | 13 | func AnchorSide_GetNamePath(obj uintptr) string { 14 | ret, _, _ := getLazyProc("AnchorSide_GetNamePath").Call(obj) 15 | return DStrToGoStr(ret) 16 | } 17 | 18 | func AnchorSide_ClassType(obj uintptr) TClass { 19 | ret, _, _ := getLazyProc("AnchorSide_ClassType").Call(obj) 20 | return TClass(ret) 21 | } 22 | 23 | func AnchorSide_ClassName(obj uintptr) string { 24 | ret, _, _ := getLazyProc("AnchorSide_ClassName").Call(obj) 25 | return DStrToGoStr(ret) 26 | } 27 | 28 | func AnchorSide_InstanceSize(obj uintptr) int32 { 29 | ret, _, _ := getLazyProc("AnchorSide_InstanceSize").Call(obj) 30 | return int32(ret) 31 | } 32 | 33 | func AnchorSide_InheritsFrom(obj uintptr, AClass TClass) bool { 34 | ret, _, _ := getLazyProc("AnchorSide_InheritsFrom").Call(obj, uintptr(AClass)) 35 | return DBoolToGoBool(ret) 36 | } 37 | 38 | func AnchorSide_Equals(obj uintptr, Obj uintptr) bool { 39 | ret, _, _ := getLazyProc("AnchorSide_Equals").Call(obj, Obj) 40 | return DBoolToGoBool(ret) 41 | } 42 | 43 | func AnchorSide_GetHashCode(obj uintptr) int32 { 44 | ret, _, _ := getLazyProc("AnchorSide_GetHashCode").Call(obj) 45 | return int32(ret) 46 | } 47 | 48 | func AnchorSide_ToString(obj uintptr) string { 49 | ret, _, _ := getLazyProc("AnchorSide_ToString").Call(obj) 50 | return DStrToGoStr(ret) 51 | } 52 | 53 | func AnchorSide_GetOwner(obj uintptr) uintptr { 54 | ret, _, _ := getLazyProc("AnchorSide_GetOwner").Call(obj) 55 | return ret 56 | } 57 | 58 | func AnchorSide_GetKind(obj uintptr) TAnchorKind { 59 | ret, _, _ := getLazyProc("AnchorSide_GetKind").Call(obj) 60 | return TAnchorKind(ret) 61 | } 62 | 63 | func AnchorSide_GetControl(obj uintptr) uintptr { 64 | ret, _, _ := getLazyProc("AnchorSide_GetControl").Call(obj) 65 | return ret 66 | } 67 | 68 | func AnchorSide_SetControl(obj uintptr, value uintptr) { 69 | _, _, _ = getLazyProc("AnchorSide_SetControl").Call(obj, value) 70 | } 71 | 72 | func AnchorSide_GetSide(obj uintptr) TAnchorSideReference { 73 | ret, _, _ := getLazyProc("AnchorSide_GetSide").Call(obj) 74 | return TAnchorSideReference(ret) 75 | } 76 | 77 | func AnchorSide_SetSide(obj uintptr, value TAnchorSideReference) { 78 | _, _, _ = getLazyProc("AnchorSide_SetSide").Call(obj, uintptr(value)) 79 | } 80 | 81 | func AnchorSide_StaticClassType() TClass { 82 | r, _, _ := getLazyProc("AnchorSide_StaticClassType").Call() 83 | return TClass(r) 84 | } 85 | -------------------------------------------------------------------------------- /lcl/cefbrowser.go: -------------------------------------------------------------------------------- 1 | package lcl 2 | 3 | import ( 4 | . "github.com/rarnu/golcl/lcl/api" 5 | . "github.com/rarnu/golcl/lcl/types" 6 | "unsafe" 7 | ) 8 | 9 | type TBrowser struct { 10 | IObject 11 | instance uintptr 12 | // 特殊情况下使用,主要应对Go的GC问题,与LCL没有太多关系。 13 | ptr unsafe.Pointer 14 | } 15 | 16 | func NewBrowser(owner IWinControl, align TAlign) *TBrowser { 17 | a := new(TBrowser) 18 | a.instance = Browser_Create(CheckPtr(owner), align) 19 | a.ptr = unsafe.Pointer(a.instance) 20 | return a 21 | } 22 | 23 | func AsBrowser(obj any) *TBrowser { 24 | instance, ptr := getInstance(obj) 25 | if instance == 0 { 26 | return nil 27 | } 28 | return &TBrowser{instance: instance, ptr: ptr} 29 | } 30 | 31 | // ApplicationFromInst 新建一个对象来自已经存在的对象实例指针。 32 | func BrowserFromInst(inst uintptr) *TBrowser { 33 | return AsBrowser(inst) 34 | } 35 | 36 | // ApplicationFromObj 新建一个对象来自已经存在的对象实例。 37 | func BrowserFromObj(obj IObject) *TBrowser { 38 | return AsBrowser(obj) 39 | } 40 | 41 | // ApplicationFromUnsafePointer 新建一个对象来自不安全的地址。注意:使用此函数可能造成一些不明情况,慎用。 42 | // Deprecated: use AsApplication. 43 | func BrowserFromUnsafePointer(ptr unsafe.Pointer) *TBrowser { 44 | return AsBrowser(ptr) 45 | } 46 | 47 | // Free 释放对象。 48 | func (c *TBrowser) Free() { 49 | if c.instance != 0 { 50 | Browser_Free(c.instance) 51 | c.instance, c.ptr = 0, nullptr 52 | } 53 | } 54 | 55 | // Instance 返回对象实例指针。 56 | func (c *TBrowser) Instance() uintptr { 57 | return c.instance 58 | } 59 | 60 | // UnsafeAddr 获取一个不安全的地址。 61 | func (c *TBrowser) UnsafeAddr() unsafe.Pointer { 62 | return c.ptr 63 | } 64 | 65 | // IsValid 检测地址是否为空。 66 | func (c *TBrowser) IsValid() bool { 67 | return c.instance != 0 68 | } 69 | 70 | // Is 检测当前对象是否继承自目标对象。 71 | func (c *TBrowser) Is() TIs { 72 | return TIs(c.instance) 73 | } 74 | 75 | func (c *TBrowser) ChromiumWindow() *TChromiumWindow { 76 | return AsChromiumWindow(Browser_GetChromiumWindow(c.instance)) 77 | } 78 | 79 | func (c *TBrowser) Chromium() *TChromium { 80 | return AsChromium(Browser_GetChromium(c.instance)) 81 | } 82 | 83 | func (c *TBrowser) OpenLinkPopup() bool { 84 | return Browser_GetOpenLinkPopup(c.instance) 85 | } 86 | 87 | func (c *TBrowser) SetOpenLinkPopup(value bool) { 88 | Browser_SetOpenLinkPopup(c.instance, value) 89 | } 90 | 91 | func (c *TBrowser) SetOnInitComplete(event TNotifyEvent) { 92 | Browser_SetOnInitComplete(c.instance, event) 93 | } 94 | 95 | func (c *TBrowser) SetOnAfterCreated(event TNotifyEvent) { 96 | Browser_SetOnAfterCreated(c.instance, event) 97 | } 98 | 99 | func (c *TBrowser) SetOnBeforeClose(event TNotifyEvent) { 100 | Browser_SetOnBeforeClose(c.instance, event) 101 | } 102 | -------------------------------------------------------------------------------- /lcl/icontrol.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | package lcl 10 | 11 | import . "github.com/rarnu/golcl/lcl/types" 12 | 13 | type IControl interface { 14 | IComponent 15 | // ---------------------方法 16 | 17 | Perform(uint32, uintptr, int) int 18 | SendToBack() 19 | Show() 20 | Hide() 21 | Refresh() 22 | Repaint() 23 | Invalidate() 24 | Realign() 25 | // ---------------------属性 26 | 27 | Align() TAlign 28 | SetAlign(TAlign) 29 | 30 | Visible() bool 31 | SetVisible(bool) 32 | 33 | Enabled() bool 34 | SetEnabled(bool) 35 | 36 | Left() int32 37 | SetLeft(int32) 38 | 39 | Top() int32 40 | SetTop(int32) 41 | 42 | Width() int32 43 | SetWidth(int32) 44 | 45 | Height() int32 46 | SetHeight(int32) 47 | 48 | Hint() string 49 | SetHint(string) 50 | 51 | ShowHint() bool 52 | SetShowHint(bool) 53 | 54 | Parent() *TWinControl 55 | SetParent(IWinControl) 56 | 57 | SetBounds(int32, int32, int32, int32) 58 | 59 | Caption() string 60 | SetCaption(string) 61 | 62 | Cursor() TCursor 63 | SetCursor(TCursor) 64 | 65 | Action() *TAction 66 | SetAction(IComponent) 67 | 68 | Anchors() TAnchors 69 | SetAnchors(TAnchors) 70 | 71 | BoundsRect() TRect 72 | SetBoundsRect(TRect) 73 | 74 | ClientHeight() int32 75 | SetClientHeight(int32) 76 | 77 | ClientWidth() int32 78 | SetClientWidth(int32) 79 | 80 | ClientOrigin() TPoint 81 | ClientRect() TRect 82 | 83 | SetTextBuf(string) 84 | 85 | PopupMenu() *TPopupMenu 86 | SetPopupMenu(IComponent) 87 | 88 | Font() *TFont 89 | SetFont(*TFont) 90 | 91 | AnchorToNeighbour(TAnchorKind, int32, IControl) 92 | AnchorParallel(TAnchorKind, int32, IControl) 93 | AnchorHorizontalCenterTo(IControl) 94 | AnchorVerticalCenterTo(IControl) 95 | AnchorSame(TAnchorKind, IControl) 96 | AnchorAsAlign(TAlign, int32) 97 | AnchorClient(int32) 98 | 99 | AnchorSide(TAnchorKind) *TAnchorSide 100 | AnchorSideLeft() *TAnchorSide 101 | AnchorSideTop() *TAnchorSide 102 | AnchorSideRight() *TAnchorSide 103 | AnchorSideBottom() *TAnchorSide 104 | 105 | BorderSpacing() *TControlBorderSpacing 106 | 107 | Floating() bool 108 | SetFloating(bool) 109 | 110 | Color() TColor 111 | SetColor(TColor) 112 | 113 | ControlStyle() TControlStyle 114 | SetControlStyle(TControlStyle) 115 | 116 | ControlState() TControlState 117 | SetControlState(TControlState) 118 | 119 | ScreenToClient(Point TPoint) TPoint 120 | ParentToClient(Point TPoint, AParent IWinControl) TPoint 121 | 122 | // ---------------------事件 123 | //SetOnClick(TNotifyEvent) 124 | } 125 | -------------------------------------------------------------------------------- /lcl/api/importFuncsChartAxisIntervalParams.go: -------------------------------------------------------------------------------- 1 | package api 2 | 3 | import ( 4 | . "github.com/rarnu/golcl/lcl/types" 5 | ) 6 | 7 | func ChartAxisIntervalParams_Create(obj uintptr) uintptr { 8 | ret, _, _ := getLazyProc("ChartAxisIntervalParams_Create").Call(obj) 9 | return ret 10 | } 11 | 12 | func ChartAxisIntervalParams_Free(obj uintptr) { 13 | _, _, _ = getLazyProc("ChartAxisIntervalParams_Free").Call(obj) 14 | } 15 | 16 | func ChartAxisIntervalParams_StaticClassType() TClass { 17 | ret, _, _ := getLazyProc("ChartAxisIntervalParams_StaticClassType").Call() 18 | return TClass(ret) 19 | } 20 | 21 | func ChartAxisIntervalParams_GetCount(obj uintptr) int32 { 22 | ret, _, _ := getLazyProc("ChartAxisIntervalParams_GetCount").Call(obj) 23 | return int32(ret) 24 | } 25 | 26 | func ChartAxisIntervalParams_SetCount(obj uintptr, value int32) { 27 | _, _, _ = getLazyProc("ChartAxisIntervalParams_SetCount").Call(obj, uintptr(value)) 28 | } 29 | 30 | func ChartAxisIntervalParams_GetMaxLength(obj uintptr) int32 { 31 | ret, _, _ := getLazyProc("ChartAxisIntervalParams_GetMaxLength").Call(obj) 32 | return int32(ret) 33 | } 34 | 35 | func ChartAxisIntervalParams_SetMaxLength(obj uintptr, value int32) { 36 | _, _, _ = getLazyProc("ChartAxisIntervalParams_SetMaxLength").Call(obj, uintptr(value)) 37 | } 38 | 39 | func ChartAxisIntervalParams_GetMinLength(obj uintptr) int32 { 40 | ret, _, _ := getLazyProc("ChartAxisIntervalParams_GetMinLength").Call(obj) 41 | return int32(ret) 42 | } 43 | 44 | func ChartAxisIntervalParams_SetMinLength(obj uintptr, value int32) { 45 | _, _, _ = getLazyProc("ChartAxisIntervalParams_SetMinLength").Call(obj, uintptr(value)) 46 | } 47 | 48 | func ChartAxisIntervalParams_GetNiceSteps(obj uintptr) string { 49 | ret, _, _ := getLazyProc("ChartAxisIntervalParams_GetNiceSteps").Call(obj) 50 | return DStrToGoStr(ret) 51 | } 52 | 53 | func ChartAxisIntervalParams_SetNiceSteps(obj uintptr, value string) { 54 | _, _, _ = getLazyProc("ChartAxisIntervalParams_SetNiceSteps").Call(obj, GoStrToDStr(value)) 55 | } 56 | 57 | func ChartAxisIntervalParams_GetOptions(obj uintptr) TAxisIntervalParamOptions { 58 | ret, _, _ := getLazyProc("ChartAxisIntervalParams_GetOptions").Call(obj) 59 | return TAxisIntervalParamOptions(ret) 60 | } 61 | 62 | func ChartAxisIntervalParams_SetOptions(obj uintptr, value TAxisIntervalParamOptions) { 63 | _, _, _ = getLazyProc("ChartAxisIntervalParams_SetOptions").Call(obj, uintptr(value)) 64 | } 65 | 66 | func ChartAxisIntervalParams_GetTolerance(obj uintptr) Cardinal { 67 | ret, _, _ := getLazyProc("ChartAxisIntervalParams_GetTolerance").Call(obj) 68 | return Cardinal(ret) 69 | } 70 | 71 | func ChartAxisIntervalParams_SetTolerance(obj uintptr, value Cardinal) { 72 | _, _, _ = getLazyProc("ChartAxisIntervalParams_SetTolerance").Call(obj, uintptr(value)) 73 | } 74 | -------------------------------------------------------------------------------- /lcl/synbatsyn.go: -------------------------------------------------------------------------------- 1 | package lcl 2 | 3 | import ( 4 | . "github.com/rarnu/golcl/lcl/api" 5 | . "github.com/rarnu/golcl/lcl/types" 6 | "unsafe" 7 | ) 8 | 9 | type TSynBatSyn struct { 10 | TSynCustomHighlighter 11 | instance uintptr 12 | ptr unsafe.Pointer 13 | } 14 | 15 | func AsSynBatSyn(obj any) *TSynBatSyn { 16 | instance, ptr := getInstance(obj) 17 | if instance == 0 { 18 | return nil 19 | } 20 | return &TSynBatSyn{instance: instance, ptr: ptr} 21 | } 22 | 23 | func SynBatSynFromInst(inst uintptr) *TSynBatSyn { 24 | return AsSynBatSyn(inst) 25 | } 26 | 27 | func SynBatSynFromObj(obj IObject) *TSynBatSyn { 28 | return AsSynBatSyn(obj) 29 | } 30 | 31 | func SynBatSynFromUnsafePointer(ptr unsafe.Pointer) *TSynBatSyn { 32 | return AsSynBatSyn(ptr) 33 | } 34 | 35 | func (s *TSynBatSyn) Instance() uintptr { 36 | return s.instance 37 | } 38 | 39 | func (s *TSynBatSyn) UnsafeAddr() unsafe.Pointer { 40 | return s.ptr 41 | } 42 | 43 | func (s *TSynBatSyn) IsValid() bool { 44 | return s.instance != 0 45 | } 46 | 47 | func (s *TSynBatSyn) Is() TIs { 48 | return TIs(s.instance) 49 | } 50 | 51 | func TSynBatSynClass() TClass { 52 | return SynBatSyn_StaticClassType() 53 | } 54 | 55 | func NewSynBatSyn(owner IComponent) *TSynBatSyn { 56 | s := new(TSynBatSyn) 57 | s.instance = SynBatSyn_Create(CheckPtr(owner)) 58 | s.ptr = unsafe.Pointer(s.instance) 59 | return s 60 | } 61 | 62 | func (s *TSynBatSyn) Free() { 63 | if s.instance != 0 { 64 | SynBatSyn_Free(s.instance) 65 | s.instance, s.ptr = 0, nullptr 66 | } 67 | } 68 | 69 | func (s *TSynBatSyn) GetEnabled() bool { 70 | return SynBatSyn_GetEnabled(s.instance) 71 | } 72 | 73 | func (s *TSynBatSyn) SetEnabled(value bool) { 74 | SynBatSyn_SetEnabled(s.instance, value) 75 | } 76 | 77 | func (s *TSynBatSyn) GetCommentAttri() *TSynHighlighterAttributes { 78 | return AsSynHighlighterAttributes(SynBatSyn_GetCommentAttri(s.instance)) 79 | } 80 | 81 | func (s *TSynBatSyn) GetIdentifierAttri() *TSynHighlighterAttributes { 82 | return AsSynHighlighterAttributes(SynBatSyn_GetIdentifierAttri(s.instance)) 83 | } 84 | 85 | func (s *TSynBatSyn) GetKeyAttri() *TSynHighlighterAttributes { 86 | return AsSynHighlighterAttributes(SynBatSyn_GetKeyAttri(s.instance)) 87 | } 88 | 89 | func (s *TSynBatSyn) GetNumberAttri() *TSynHighlighterAttributes { 90 | return AsSynHighlighterAttributes(SynBatSyn_GetNumberAttri(s.instance)) 91 | } 92 | 93 | func (s *TSynBatSyn) GetSpaceAttri() *TSynHighlighterAttributes { 94 | return AsSynHighlighterAttributes(SynBatSyn_GetSpaceAttri(s.instance)) 95 | } 96 | 97 | func (s *TSynBatSyn) GetVariableAttri() *TSynHighlighterAttributes { 98 | return AsSynHighlighterAttributes(SynBatSyn_GetVariableAttri(s.instance)) 99 | } 100 | -------------------------------------------------------------------------------- /lcl/api/canvasdef.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | package api 10 | 11 | import ( 12 | "unsafe" 13 | 14 | . "github.com/rarnu/golcl/lcl/types" 15 | ) 16 | 17 | func Canvas_BrushCopy(obj uintptr, dest TRect, bitmap uintptr, source TRect, color TColor) { 18 | _, _, _ = canvas_BrushCopy.Call(obj, uintptr(unsafe.Pointer(&dest)), bitmap, uintptr(unsafe.Pointer(&source)), uintptr(color)) 19 | } 20 | 21 | func Canvas_CopyRect(obj uintptr, dest TRect, canvas uintptr, source TRect) { 22 | _, _, _ = canvas_CopyRect.Call(obj, uintptr(unsafe.Pointer(&dest)), canvas, uintptr(unsafe.Pointer(&source))) 23 | } 24 | 25 | func Canvas_Draw1(obj uintptr, x, y int32, graphic uintptr) { 26 | _, _, _ = canvas_Draw1.Call(obj, uintptr(x), uintptr(y), graphic) 27 | } 28 | 29 | func Canvas_Draw2(obj uintptr, x, y int32, graphic uintptr, opacity uint8) { 30 | _, _, _ = canvas_Draw2.Call(obj, uintptr(x), uintptr(y), graphic, uintptr(opacity)) 31 | } 32 | 33 | func Canvas_DrawFocusRect(obj uintptr, aRect TRect) { 34 | _, _, _ = canvas_DrawFocusRect.Call(obj, uintptr(unsafe.Pointer(&aRect))) 35 | } 36 | 37 | func Canvas_FillRect(obj uintptr, aRect TRect) { 38 | _, _, _ = canvas_FillRect.Call(obj, uintptr(unsafe.Pointer(&aRect))) 39 | } 40 | 41 | func Canvas_FrameRect(obj uintptr, aRect TRect) { 42 | _, _, _ = canvas_FrameRect.Call(obj, uintptr(unsafe.Pointer(&aRect))) 43 | } 44 | 45 | func Canvas_TextRect2(obj uintptr, aRect *TRect, text string, textFormat TTextFormat) { 46 | _, _, _ = canvas_TextRect2.Call(obj, uintptr(unsafe.Pointer(aRect)), GoStrToDStr(text), uintptr(textFormat)) 47 | } 48 | 49 | func Canvas_TextRect3(obj uintptr, aRect *TRect, text string, textFormat TTextFormat) { 50 | _, _, _ = canvas_TextRect2.Call(obj, uintptr(unsafe.Pointer(aRect)), GoStrToDStr(text), 0, uintptr(textFormat)) 51 | } 52 | 53 | func Canvas_TextRect1(obj uintptr, aRect TRect, x, y int32, text string) { 54 | _, _, _ = canvas_TextRect1.Call(obj, uintptr(unsafe.Pointer(&aRect)), uintptr(x), uintptr(y), GoStrToDStr(text)) 55 | } 56 | 57 | func Canvas_Polygon(obj uintptr, points []TPoint) { 58 | if len(points) == 0 { 59 | return 60 | } 61 | _, _, _ = canvas_Polygon.Call(obj, uintptr(unsafe.Pointer(&points[0])), uintptr(len(points))) 62 | } 63 | 64 | func Canvas_Polyline(obj uintptr, points []TPoint) { 65 | if len(points) == 0 { 66 | return 67 | } 68 | _, _, _ = canvas_Polyline.Call(obj, uintptr(unsafe.Pointer(&points[0])), uintptr(len(points))) 69 | } 70 | 71 | func Canvas_PolyBezier(obj uintptr, points []TPoint) { 72 | if len(points) == 0 { 73 | return 74 | } 75 | _, _, _ = canvas_PolyBezier.Call(obj, uintptr(unsafe.Pointer(&points[0])), uintptr(len(points))) 76 | } 77 | -------------------------------------------------------------------------------- /lcl/api/importFuncsSynShellSyn.go: -------------------------------------------------------------------------------- 1 | package api 2 | 3 | import ( 4 | . "github.com/rarnu/golcl/lcl/types" 5 | ) 6 | 7 | func SynUNIXShellScriptSyn_Create(owner uintptr) uintptr { 8 | r, _, _ := getLazyProc("SynUNIXShellScriptSyn_Create").Call(owner) 9 | return r 10 | } 11 | 12 | func SynUNIXShellScriptSyn_Free(obj uintptr) { 13 | _, _, _ = getLazyProc("SynUNIXShellScriptSyn_Free").Call(obj) 14 | } 15 | 16 | func SynUNIXShellScriptSyn_StaticClassType() TClass { 17 | r, _, _ := getLazyProc("SynUNIXShellScriptSyn_StaticClassType").Call() 18 | return TClass(r) 19 | } 20 | 21 | func SynUNIXShellScriptSyn_GetEnabled(obj uintptr) bool { 22 | r, _, _ := getLazyProc("SynUNIXShellScriptSyn_GetEnabled").Call(obj) 23 | return DBoolToGoBool(r) 24 | } 25 | 26 | func SynUNIXShellScriptSyn_SetEnabled(obj uintptr, value bool) { 27 | _, _, _ = getLazyProc("SynUNIXShellScriptSyn_SetEnabled").Call(obj, GoBoolToDBool(value)) 28 | } 29 | 30 | func SynUNIXShellScriptSyn_GetCommentAttri(obj uintptr) uintptr { 31 | r, _, _ := getLazyProc("SynUNIXShellScriptSyn_GetCommentAttri").Call(obj) 32 | return r 33 | } 34 | 35 | func SynUNIXShellScriptSyn_GetIdentifierAttri(obj uintptr) uintptr { 36 | r, _, _ := getLazyProc("SynUNIXShellScriptSyn_GetIdentifierAttri").Call(obj) 37 | return r 38 | } 39 | 40 | func SynUNIXShellScriptSyn_GetKeyAttri(obj uintptr) uintptr { 41 | r, _, _ := getLazyProc("SynUNIXShellScriptSyn_GetKeyAttri").Call(obj) 42 | return r 43 | } 44 | 45 | func SynUNIXShellScriptSyn_GetSecondKeyAttri(obj uintptr) uintptr { 46 | r, _, _ := getLazyProc("SynUNIXShellScriptSyn_GetSecondKeyAttri").Call(obj) 47 | return r 48 | } 49 | 50 | func SynUNIXShellScriptSyn_GetNumberAttri(obj uintptr) uintptr { 51 | r, _, _ := getLazyProc("SynUNIXShellScriptSyn_GetNumberAttri").Call(obj) 52 | return r 53 | } 54 | 55 | func SynUNIXShellScriptSyn_GetSpaceAttri(obj uintptr) uintptr { 56 | r, _, _ := getLazyProc("SynUNIXShellScriptSyn_GetSpaceAttri").Call(obj) 57 | return r 58 | } 59 | 60 | func SynUNIXShellScriptSyn_GetStringAttri(obj uintptr) uintptr { 61 | r, _, _ := getLazyProc("SynUNIXShellScriptSyn_GetStringAttri").Call(obj) 62 | return r 63 | } 64 | 65 | func SynUNIXShellScriptSyn_GetSymbolAttri(obj uintptr) uintptr { 66 | r, _, _ := getLazyProc("SynUNIXShellScriptSyn_GetSymbolAttri").Call(obj) 67 | return r 68 | } 69 | 70 | func SynUNIXShellScriptSyn_GetVarAttri(obj uintptr) uintptr { 71 | r, _, _ := getLazyProc("SynUNIXShellScriptSyn_GetVarAttri").Call(obj) 72 | return r 73 | } 74 | 75 | func SynUNIXShellScriptSyn_GetSecondKeyWords(obj uintptr) uintptr { 76 | r, _, _ := getLazyProc("SynUNIXShellScriptSyn_GetSecondKeyWords").Call(obj) 77 | return r 78 | } 79 | 80 | func SynUNIXShellScriptSyn_SetSecondKeyWords(obj uintptr, value uintptr) { 81 | _, _, _ = getLazyProc("SynUNIXShellScriptSyn_SetSecondKeyWords").Call(obj, value) 82 | } 83 | -------------------------------------------------------------------------------- /lcl/api/importFuncsChartRange.go: -------------------------------------------------------------------------------- 1 | package api 2 | 3 | import ( 4 | . "github.com/rarnu/golcl/lcl/types" 5 | "unsafe" 6 | ) 7 | 8 | func ChartRange_Create(obj uintptr) uintptr { 9 | ret, _, _ := getLazyProc("ChartRange_Create").Call(obj) 10 | return ret 11 | } 12 | 13 | func ChartRange_Free(obj uintptr) { 14 | _, _, _ = getLazyProc("ChartRange_Free").Call(obj) 15 | } 16 | 17 | func ChartRange_Assign(obj uintptr, source uintptr) { 18 | _, _, _ = getLazyProc("ChartRange_Assign").Call(obj, source) 19 | } 20 | 21 | func ChartRange_CheckBoundsOrder(obj uintptr) { 22 | _, _, _ = getLazyProc("ChartRange_CheckBoundsOrder").Call(obj) 23 | } 24 | 25 | func ChartRange_Intersect(obj uintptr, AMin float64, AMax float64) { 26 | _, _, _ = getLazyProc("ChartRange_Intersect").Call(obj, uintptr(unsafe.Pointer(&AMin)), uintptr(unsafe.Pointer(&AMax))) 27 | } 28 | 29 | func ChartRange_GetMax(obj uintptr) float64 { 30 | var ret float64 31 | _, _, _ = getLazyProc("ChartRange_GetMax").Call(obj, uintptr(unsafe.Pointer(&ret))) 32 | return ret 33 | } 34 | 35 | func ChartRange_SetMax(obj uintptr, AValue float64) { 36 | _, _, _ = getLazyProc("ChartRange_SetMax").Call(obj, uintptr(unsafe.Pointer(&AValue))) 37 | } 38 | 39 | func ChartRange_GetMin(obj uintptr) float64 { 40 | var ret float64 41 | _, _, _ = getLazyProc("ChartRange_GetMin").Call(obj, uintptr(unsafe.Pointer(&ret))) 42 | return ret 43 | } 44 | 45 | func ChartRange_SetMin(obj uintptr, AValue float64) { 46 | _, _, _ = getLazyProc("ChartRange_SetMin").Call(obj, uintptr(unsafe.Pointer(&AValue))) 47 | } 48 | 49 | func ChartRange_GetUseMax(obj uintptr) bool { 50 | ret, _, _ := getLazyProc("ChartRange_GetUseMax").Call(obj) 51 | return DBoolToGoBool(ret) 52 | } 53 | 54 | func ChartRange_SetUseMax(obj uintptr, AValue bool) { 55 | _, _, _ = getLazyProc("ChartRange_SetUseMax").Call(obj, GoBoolToDBool(AValue)) 56 | } 57 | 58 | func ChartRange_GetUseMin(obj uintptr) bool { 59 | ret, _, _ := getLazyProc("ChartRange_GetUseMin").Call(obj) 60 | return DBoolToGoBool(ret) 61 | } 62 | 63 | func ChartRange_SetUseMin(obj uintptr, AValue bool) { 64 | _, _, _ = getLazyProc("ChartRange_SetUseMin").Call(obj, GoBoolToDBool(AValue)) 65 | } 66 | 67 | func ChartRange_StaticClassType() TClass { 68 | ret, _, _ := getLazyProc("ChartRange_StaticClassType").Call() 69 | return TClass(ret) 70 | } 71 | 72 | func ChartRange_GetOwner(obj uintptr) uintptr { 73 | ret, _, _ := getLazyProc("ChartRange_GetOwner").Call(obj) 74 | return ret 75 | } 76 | 77 | func ChartRange_SetOwner(obj uintptr, AValue uintptr) { 78 | _, _, _ = getLazyProc("ChartRange_SetOwner").Call(obj, AValue) 79 | } 80 | 81 | func ChartRange_GetVisible(obj uintptr) bool { 82 | ret, _, _ := getLazyProc("ChartRange_GetVisible").Call(obj) 83 | return DBoolToGoBool(ret) 84 | } 85 | 86 | func ChartRange_SetVisible(obj uintptr, AValue bool) { 87 | _, _, _ = getLazyProc("ChartRange_SetVisible").Call(obj, GoBoolToDBool(AValue)) 88 | } 89 | -------------------------------------------------------------------------------- /lcl/synvbsyn.go: -------------------------------------------------------------------------------- 1 | package lcl 2 | 3 | import ( 4 | . "github.com/rarnu/golcl/lcl/api" 5 | . "github.com/rarnu/golcl/lcl/types" 6 | "unsafe" 7 | ) 8 | 9 | type TSynVBSyn struct { 10 | TSynCustomHighlighter 11 | instance uintptr 12 | ptr unsafe.Pointer 13 | } 14 | 15 | func AsSynVBSyn(obj any) *TSynVBSyn { 16 | instance, ptr := getInstance(obj) 17 | if instance == 0 { 18 | return nil 19 | } 20 | return &TSynVBSyn{instance: instance, ptr: ptr} 21 | } 22 | 23 | func SynVBSynFromInst(inst uintptr) *TSynVBSyn { 24 | return AsSynVBSyn(inst) 25 | } 26 | 27 | func SynVBSynFromObj(obj IObject) *TSynVBSyn { 28 | return AsSynVBSyn(obj) 29 | } 30 | 31 | func SynVBSynFromUnsafePointer(ptr unsafe.Pointer) *TSynVBSyn { 32 | return AsSynVBSyn(ptr) 33 | } 34 | 35 | func (s *TSynVBSyn) Instance() uintptr { 36 | return s.instance 37 | } 38 | 39 | func (s *TSynVBSyn) UnsafeAddr() unsafe.Pointer { 40 | return s.ptr 41 | } 42 | 43 | func (s *TSynVBSyn) IsValid() bool { 44 | return s.instance != 0 45 | } 46 | 47 | func (s *TSynVBSyn) Is() TIs { 48 | return TIs(s.instance) 49 | } 50 | 51 | func TSynVBSynClass() TClass { 52 | return SynVBSyn_StaticClassType() 53 | } 54 | 55 | func NewSynVBSyn(owner IComponent) *TSynVBSyn { 56 | s := new(TSynVBSyn) 57 | s.instance = SynVBSyn_Create(CheckPtr(owner)) 58 | s.ptr = unsafe.Pointer(s.instance) 59 | return s 60 | } 61 | 62 | func (s *TSynVBSyn) Free() { 63 | if s.instance != 0 { 64 | SynVBSyn_Free(s.instance) 65 | s.instance, s.ptr = 0, nullptr 66 | } 67 | } 68 | 69 | func (s *TSynVBSyn) GetEnabled() bool { 70 | return SynVBSyn_GetEnabled(s.instance) 71 | } 72 | 73 | func (s *TSynVBSyn) SetEnabled(value bool) { 74 | SynVBSyn_SetEnabled(s.instance, value) 75 | } 76 | 77 | func (s *TSynVBSyn) GetCommentAttri() *TSynHighlighterAttributes { 78 | return AsSynHighlighterAttributes(SynVBSyn_GetCommentAttri(s.instance)) 79 | } 80 | 81 | func (s *TSynVBSyn) GetIdentifierAttri() *TSynHighlighterAttributes { 82 | return AsSynHighlighterAttributes(SynVBSyn_GetIdentifierAttri(s.instance)) 83 | } 84 | 85 | func (s *TSynVBSyn) GetKeyAttri() *TSynHighlighterAttributes { 86 | return AsSynHighlighterAttributes(SynVBSyn_GetKeyAttri(s.instance)) 87 | } 88 | 89 | func (s *TSynVBSyn) GetNumberAttri() *TSynHighlighterAttributes { 90 | return AsSynHighlighterAttributes(SynVBSyn_GetNumberAttri(s.instance)) 91 | } 92 | 93 | func (s *TSynVBSyn) GetSpaceAttri() *TSynHighlighterAttributes { 94 | return AsSynHighlighterAttributes(SynVBSyn_GetSpaceAttri(s.instance)) 95 | } 96 | 97 | func (s *TSynVBSyn) GetStringAttri() *TSynHighlighterAttributes { 98 | return AsSynHighlighterAttributes(SynVBSyn_GetStringAttri(s.instance)) 99 | } 100 | 101 | func (s *TSynVBSyn) GetSymbolAttri() *TSynHighlighterAttributes { 102 | return AsSynHighlighterAttributes(SynVBSyn_GetSymbolAttri(s.instance)) 103 | } 104 | -------------------------------------------------------------------------------- /lcl/api/importFuncsSynHtmlSyn.go: -------------------------------------------------------------------------------- 1 | package api 2 | 3 | import ( 4 | . "github.com/rarnu/golcl/lcl/types" 5 | ) 6 | 7 | func SynHTMLSyn_Create(owner uintptr) uintptr { 8 | r, _, _ := getLazyProc("SynHTMLSyn_Create").Call(owner) 9 | return r 10 | } 11 | 12 | func SynHTMLSyn_Free(obj uintptr) { 13 | _, _, _ = getLazyProc("SynHTMLSyn_Free").Call(obj) 14 | } 15 | 16 | func SynHTMLSyn_StaticClassType() TClass { 17 | r, _, _ := getLazyProc("SynHTMLSyn_StaticClassType").Call() 18 | return TClass(r) 19 | } 20 | 21 | func SynHTMLSyn_GetEnabled(obj uintptr) bool { 22 | r, _, _ := getLazyProc("SynHTMLSyn_GetEnabled").Call(obj) 23 | return DBoolToGoBool(r) 24 | } 25 | 26 | func SynHTMLSyn_SetEnabled(obj uintptr, value bool) { 27 | _, _, _ = getLazyProc("SynHTMLSyn_SetEnabled").Call(obj, GoBoolToDBool(value)) 28 | } 29 | 30 | func SynHTMLSyn_GetAndAttri(obj uintptr) uintptr { 31 | r, _, _ := getLazyProc("SynHTMLSyn_GetAndAttri").Call(obj) 32 | return r 33 | } 34 | 35 | func SynHTMLSyn_GetASPAttri(obj uintptr) uintptr { 36 | r, _, _ := getLazyProc("SynHTMLSyn_GetASPAttri").Call(obj) 37 | return r 38 | } 39 | 40 | func SynHTMLSyn_GetCDATAAttri(obj uintptr) uintptr { 41 | r, _, _ := getLazyProc("SynHTMLSyn_GetCDATAAttri").Call(obj) 42 | return r 43 | } 44 | 45 | func SynHTMLSyn_GetDOCTYPEAttri(obj uintptr) uintptr { 46 | r, _, _ := getLazyProc("SynHTMLSyn_GetDOCTYPEAttri").Call(obj) 47 | return r 48 | } 49 | 50 | func SynHTMLSyn_GetCommentAttri(obj uintptr) uintptr { 51 | r, _, _ := getLazyProc("SynHTMLSyn_GetCommentAttri").Call(obj) 52 | return r 53 | } 54 | 55 | func SynHTMLSyn_GetIdentifierAttri(obj uintptr) uintptr { 56 | r, _, _ := getLazyProc("SynHTMLSyn_GetIdentifierAttri").Call(obj) 57 | return r 58 | } 59 | 60 | func SynHTMLSyn_GetKeyAttri(obj uintptr) uintptr { 61 | r, _, _ := getLazyProc("SynHTMLSyn_GetKeyAttri").Call(obj) 62 | return r 63 | } 64 | 65 | func SynHTMLSyn_GetSpaceAttri(obj uintptr) uintptr { 66 | r, _, _ := getLazyProc("SynHTMLSyn_GetSpaceAttri").Call(obj) 67 | return r 68 | } 69 | 70 | func SynHTMLSyn_GetSymbolAttri(obj uintptr) uintptr { 71 | r, _, _ := getLazyProc("SynHTMLSyn_GetSymbolAttri").Call(obj) 72 | return r 73 | } 74 | 75 | func SynHTMLSyn_GetTextAttri(obj uintptr) uintptr { 76 | r, _, _ := getLazyProc("SynHTMLSyn_GetTextAttri").Call(obj) 77 | return r 78 | } 79 | 80 | func SynHTMLSyn_GetUndefKeyAttri(obj uintptr) uintptr { 81 | r, _, _ := getLazyProc("SynHTMLSyn_GetUndefKeyAttri").Call(obj) 82 | return r 83 | } 84 | 85 | func SynHTMLSyn_GetValueAttri(obj uintptr) uintptr { 86 | r, _, _ := getLazyProc("SynHTMLSyn_GetValueAttri").Call(obj) 87 | return r 88 | } 89 | 90 | func SynHTMLSyn_GetMode(obj uintptr) TSynHTMLSynMode { 91 | r, _, _ := getLazyProc("SynHTMLSyn_GetMode").Call(obj) 92 | return TSynHTMLSynMode(r) 93 | } 94 | 95 | func SynHTMLSyn_SetMode(obj uintptr, value TSynHTMLSynMode) { 96 | _, _, _ = getLazyProc("SynHTMLSyn_SetMode").Call(obj, uintptr(value)) 97 | } 98 | -------------------------------------------------------------------------------- /lcl/syngutter.go: -------------------------------------------------------------------------------- 1 | package lcl 2 | 3 | import ( 4 | . "github.com/rarnu/golcl/lcl/api" 5 | . "github.com/rarnu/golcl/lcl/types" 6 | "unsafe" 7 | ) 8 | 9 | type TSynGutter struct { 10 | IObject 11 | instance uintptr 12 | ptr unsafe.Pointer 13 | } 14 | 15 | func AsSynGutter(obj any) *TSynGutter { 16 | instance, ptr := getInstance(obj) 17 | if instance == 0 { 18 | return nil 19 | } 20 | return &TSynGutter{instance: instance, ptr: ptr} 21 | } 22 | 23 | func SynGutterFromInst(inst uintptr) *TSynGutter { 24 | return AsSynGutter(inst) 25 | } 26 | 27 | func SynGutterFromObj(obj IObject) *TSynGutter { 28 | return AsSynGutter(obj) 29 | } 30 | 31 | func SynGutterFromUnsafePointer(ptr unsafe.Pointer) *TSynGutter { 32 | return AsSynGutter(ptr) 33 | } 34 | 35 | func (s *TSynGutter) Instance() uintptr { 36 | return s.instance 37 | } 38 | 39 | func (s *TSynGutter) UnsafeAddr() unsafe.Pointer { 40 | return s.ptr 41 | } 42 | 43 | func (s *TSynGutter) IsValid() bool { 44 | return s.instance != 0 45 | } 46 | 47 | func (s *TSynGutter) Is() TIs { 48 | return TIs(s.instance) 49 | } 50 | 51 | func (s *TSynGutter) Free() { 52 | if s.instance != 0 { 53 | SynGutter_Free(s.instance) 54 | s.instance, s.ptr = 0, nullptr 55 | } 56 | } 57 | 58 | func (s *TSynGutter) ClassName() string { 59 | return SynGutter_ClassName(s.instance) 60 | } 61 | 62 | func (s *TSynGutter) GetHashCode() int32 { 63 | return SynGutter_GetHashCode(s.instance) 64 | } 65 | 66 | func (s *TSynGutter) Equals(obj IObject) bool { 67 | return SynGutter_Equals(s.instance, CheckPtr(obj)) 68 | } 69 | 70 | func (s *TSynGutter) ClassType() TClass { 71 | return SynGutter_ClassType(s.instance) 72 | } 73 | 74 | func (s *TSynGutter) InstanceSize() int32 { 75 | return SynGutter_InstanceSize(s.instance) 76 | } 77 | 78 | func (s *TSynGutter) InheritsFrom(aClass TClass) bool { 79 | return SynGutter_InheritsFrom(s.instance, aClass) 80 | } 81 | 82 | func TSynGutterClass() TClass { 83 | return SynGutter_StaticClassType() 84 | } 85 | 86 | func (s *TSynGutter) GetAutoSize() bool { 87 | return SynGutter_GetAutoSize(s.instance) 88 | } 89 | 90 | func (s *TSynGutter) SetAutoSize(value bool) { 91 | SynGutter_SetAutoSize(s.instance, value) 92 | } 93 | 94 | func (s *TSynGutter) GetColor() TColor { 95 | return SynGutter_GetColor(s.instance) 96 | } 97 | 98 | func (s *TSynGutter) SetColor(value TColor) { 99 | SynGutter_SetColor(s.instance, value) 100 | } 101 | 102 | func (s *TSynGutter) GetVisible() bool { 103 | return SynGutter_GetVisible(s.instance) 104 | } 105 | 106 | func (s *TSynGutter) SetVisible(value bool) { 107 | SynGutter_SetVisible(s.instance, value) 108 | } 109 | 110 | func (s *TSynGutter) GetWidth() int32 { 111 | return SynGutter_GetWidth(s.instance) 112 | } 113 | 114 | func (s *TSynGutter) SetWidth(value int32) { 115 | SynGutter_SetWidth(s.instance, value) 116 | } 117 | -------------------------------------------------------------------------------- /lcl/win/gdi32dll.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | //go:build windows 10 | 11 | package win 12 | 13 | import ( 14 | "syscall" 15 | 16 | "unsafe" 17 | 18 | . "github.com/rarnu/golcl/lcl/types" 19 | ) 20 | 21 | var ( 22 | gdi32dll = syscall.NewLazyDLL("gdi32.dll") 23 | 24 | _CreateCompatibleDC = gdi32dll.NewProc("CreateCompatibleDC") 25 | _CreateDIBSection = gdi32dll.NewProc("CreateDIBSection") 26 | _SelectObject = gdi32dll.NewProc("SelectObject") 27 | _DeleteDC = gdi32dll.NewProc("DeleteDC") 28 | _DeleteObject = gdi32dll.NewProc("DeleteObject") 29 | _CreatePen = gdi32dll.NewProc("CreatePen") 30 | _SetROP2 = gdi32dll.NewProc("SetROP2") 31 | _Rectangle = gdi32dll.NewProc("Rectangle") 32 | _SaveDC = gdi32dll.NewProc("SaveDC") 33 | _RestoreDC = gdi32dll.NewProc("RestoreDC") 34 | _SetBkMode = gdi32dll.NewProc("SetBkMode") 35 | _SetTextColor = gdi32dll.NewProc("SetTextColor") 36 | ) 37 | 38 | func CreateCompatibleDC(dc HDC) HDC { 39 | r, _, _ := _CreateCompatibleDC.Call(uintptr(dc)) 40 | return HDC(r) 41 | } 42 | 43 | func CreateDIBSection(dc HDC, p2 *TBitmapInfo, p3 uint32, p4 *uintptr, p5 uintptr, p6 uint32) HBITMAP { 44 | r, _, _ := _CreateDIBSection.Call(uintptr(dc), uintptr(unsafe.Pointer(p2)), uintptr(p3), uintptr(unsafe.Pointer(p4)), p5, uintptr(p6)) 45 | return HBITMAP(r) 46 | } 47 | 48 | func SelectObject(dc HDC, p2 HGDIOBJ) HGDIOBJ { 49 | r, _, _ := _SelectObject.Call(uintptr(dc), uintptr(p2)) 50 | return HGDIOBJ(r) 51 | } 52 | 53 | func DeleteDC(dc HDC) bool { 54 | r, _, _ := _DeleteDC.Call(uintptr(dc)) 55 | return r != 0 56 | } 57 | 58 | func DeleteObject(p1 HGDIOBJ) bool { 59 | r, _, _ := _DeleteObject.Call(uintptr(p1)) 60 | return r != 0 61 | } 62 | 63 | func CreatePen(style, width int32, color uint32) HPEN { 64 | r, _, _ := _CreatePen.Call(uintptr(style), uintptr(width), uintptr(color)) 65 | return HPEN(r) 66 | } 67 | 68 | func SetROP2(dc HDC, p2 int32) int32 { 69 | r, _, _ := _SetROP2.Call(uintptr(dc), uintptr(p2)) 70 | return int32(r) 71 | } 72 | 73 | func Rectangle(dc HDC, x1, y1, x2, y2 int32) bool { 74 | r, _, _ := _Rectangle.Call(uintptr(dc), uintptr(x1), uintptr(y1), uintptr(x2), uintptr(y2)) 75 | return r != 0 76 | } 77 | 78 | func SetBkMode(dC HDC, bkMode int32) int32 { 79 | r, _, _ := _SetBkMode.Call(uintptr(dC), uintptr(bkMode)) 80 | return int32(r) 81 | } 82 | 83 | func SaveDC(dC HDC) int32 { 84 | r, _, _ := _SaveDC.Call(uintptr(dC)) 85 | return int32(r) 86 | } 87 | 88 | func RestoreDC(dC HDC, savedDC int32) bool { 89 | r, _, _ := _RestoreDC.Call(uintptr(dC), uintptr(savedDC)) 90 | return r != 0 91 | } 92 | 93 | func SetTextColor(dC HDC, color uint32) uint32 { 94 | r, _, _ := _SetTextColor.Call(uintptr(dC), uintptr(color)) 95 | return uint32(r) 96 | } 97 | -------------------------------------------------------------------------------- /lcl/syntexsyn.go: -------------------------------------------------------------------------------- 1 | package lcl 2 | 3 | import ( 4 | . "github.com/rarnu/golcl/lcl/api" 5 | . "github.com/rarnu/golcl/lcl/types" 6 | "unsafe" 7 | ) 8 | 9 | type TSynTeXSyn struct { 10 | TSynCustomHighlighter 11 | instance uintptr 12 | ptr unsafe.Pointer 13 | } 14 | 15 | func AsSynTeXSyn(obj any) *TSynTeXSyn { 16 | instance, ptr := getInstance(obj) 17 | if instance == 0 { 18 | return nil 19 | } 20 | return &TSynTeXSyn{instance: instance, ptr: ptr} 21 | } 22 | 23 | func SynTeXSynFromInst(inst uintptr) *TSynTeXSyn { 24 | return AsSynTeXSyn(inst) 25 | } 26 | 27 | func SynTeXSynFromObj(obj IObject) *TSynTeXSyn { 28 | return AsSynTeXSyn(obj) 29 | } 30 | 31 | func SynTeXSynFromUnsafePointer(ptr unsafe.Pointer) *TSynTeXSyn { 32 | return AsSynTeXSyn(ptr) 33 | } 34 | 35 | func (s *TSynTeXSyn) Instance() uintptr { 36 | return s.instance 37 | } 38 | 39 | func (s *TSynTeXSyn) UnsafeAddr() unsafe.Pointer { 40 | return s.ptr 41 | } 42 | 43 | func (s *TSynTeXSyn) IsValid() bool { 44 | return s.instance != 0 45 | } 46 | 47 | func (s *TSynTeXSyn) Is() TIs { 48 | return TIs(s.instance) 49 | } 50 | 51 | func TSynTeXSynClass() TClass { 52 | return SynTeXSyn_StaticClassType() 53 | } 54 | 55 | func NewSynTeXSyn(owner IComponent) *TSynTeXSyn { 56 | s := new(TSynTeXSyn) 57 | s.instance = SynTeXSyn_Create(CheckPtr(owner)) 58 | s.ptr = unsafe.Pointer(s.instance) 59 | return s 60 | } 61 | 62 | func (s *TSynTeXSyn) Free() { 63 | if s.instance != 0 { 64 | SynTeXSyn_Free(s.instance) 65 | s.instance, s.ptr = 0, nullptr 66 | } 67 | } 68 | 69 | func (s *TSynTeXSyn) GetEnabled() bool { 70 | return SynTeXSyn_GetEnabled(s.instance) 71 | } 72 | 73 | func (s *TSynTeXSyn) SetEnabled(value bool) { 74 | SynTeXSyn_SetEnabled(s.instance, value) 75 | } 76 | 77 | func (s *TSynTeXSyn) GetCommentAttri() *TSynHighlighterAttributes { 78 | return AsSynHighlighterAttributes(SynTeXSyn_GetCommentAttri(s.instance)) 79 | } 80 | 81 | func (s *TSynTeXSyn) GetTextAttri() *TSynHighlighterAttributes { 82 | return AsSynHighlighterAttributes(SynTeXSyn_GetTextAttri(s.instance)) 83 | } 84 | 85 | func (s *TSynTeXSyn) GetControlSequenceAttri() *TSynHighlighterAttributes { 86 | return AsSynHighlighterAttributes(SynTeXSyn_GetControlSequenceAttri(s.instance)) 87 | } 88 | 89 | func (s *TSynTeXSyn) GetMathmodeAttri() *TSynHighlighterAttributes { 90 | return AsSynHighlighterAttributes(SynTeXSyn_GetMathmodeAttri(s.instance)) 91 | } 92 | 93 | func (s *TSynTeXSyn) GetSpaceAttri() *TSynHighlighterAttributes { 94 | return AsSynHighlighterAttributes(SynTeXSyn_GetSpaceAttri(s.instance)) 95 | } 96 | 97 | func (s *TSynTeXSyn) GetBraceAttri() *TSynHighlighterAttributes { 98 | return AsSynHighlighterAttributes(SynTeXSyn_GetBraceAttri(s.instance)) 99 | } 100 | 101 | func (s *TSynTeXSyn) GetBracketAttri() *TSynHighlighterAttributes { 102 | return AsSynHighlighterAttributes(SynTeXSyn_GetBracketAttri(s.instance)) 103 | } 104 | -------------------------------------------------------------------------------- /lcl/applicationdef.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | package lcl 10 | 11 | import ( 12 | . "github.com/rarnu/golcl/lcl/api" 13 | ) 14 | 15 | /* 16 | TApplication.CreateForm 一般不建议使用NewForm,而优先使用CreateForm 17 | 18 | -------------------- 用法一-------------------------------------- 19 | 1、mainForm := vcl.Application.CreateForm() // 直接返回,不推荐使用 20 | 例: 21 | mainForm := vcl.Application.CreateForm() 22 | mainForm.SetOnClick(func(sender vcl.IObject) { 23 | vcl.ShowMessage("msg") 24 | }) 25 | 26 | 27 | -------------------- 用法二-------------------------------------- 28 | 2、vcl.Application.CreateForm(&mainForm) // 无资源或者自动加载对应类名的资源,当无资源时只会绑定窗口的事件,不会绑定子组件事件,有资源则自动绑定所有事件 29 | 例: 30 | type TMainForm struct { 31 | *vcl.TForm 32 | } 33 | 34 | var mainForm *TMainForm 35 | vcl.Application.CreateForm(&mainForm) 36 | 37 | func (f *TMainForm)OnFormCreate(sender vcl.IObject) { 38 | fmt.Println("FormCreate") 39 | } 40 | 41 | func (f *TMainForm)OnFormClick(sender vcl.IObject) { 42 | vcl.ShowMessage("click") 43 | } 44 | 45 | 46 | -------------------- 用法三-------------------------------------- 47 | 3、vcl.Application.CreateForm(&mainForm, true) // 无资源或者自动加载对应类名的资源,当第二个参数为true时在OnFormCreate调用完后会绑定子组件事件(当查找到对应的资源则第二个参数无效) 48 | 例: 49 | type TMainForm struct { 50 | *vcl.TForm 51 | Btn1 *vcl.TButton 52 | } 53 | 54 | var mainForm *TMainForm 55 | vcl.Application.CreateForm(&mainForm, true) 56 | 57 | func (f *TMainForm)OnFormCreate(sender vcl.IObject) { 58 | fmt.Println("FormCreate") 59 | f.Btn1 = vcl.NewButton(f) 60 | f.Btn1.SetParent(f) 61 | } 62 | 63 | func (f *TMainForm)OnFormClick(sender vcl.IObject) { 64 | vcl.ShowMessage("click") 65 | } 66 | 67 | func (f *TMainForm)OnBtn1Click(Sender vcl.IObject) { 68 | vcl.ShowMessage("Btn1 Click") 69 | } 70 | 71 | 72 | -------------------- 用法四-------------------------------------- 73 | // 将来准备废弃 74 | 4、vcl.Application.CreateForm("form1.gfm", &mainForm) // 从资源文件中填充子组件,并绑定所有事件 75 | -------------------- 用法五-------------------------------------- 76 | // 将来准备废弃 77 | 5、vcl.Application.CreateForm(form1Bytes, &mainForm) // 从字节中填充子组件,并绑定所有事件 78 | */ 79 | 80 | // 创建一个TForm。 81 | // 82 | // Create a TForm. 83 | func (a *TApplication) CreateForm(fields ...any) *TForm { 84 | return AsForm(resObjectBuild(0, nil, a.instance, fields...)) 85 | } 86 | 87 | // 运行APP。 88 | // 89 | // Run the app. 90 | func (a *TApplication) Run() { 91 | Application_Run(a.instance) 92 | } 93 | 94 | // 初始APP信息。 95 | // 96 | // Initial APP information. 97 | func (a *TApplication) Initialize() { 98 | Application_Initialize(a.instance) 99 | } 100 | -------------------------------------------------------------------------------- /lcl/api/importFuncsSynPythonSyn.go: -------------------------------------------------------------------------------- 1 | package api 2 | 3 | import ( 4 | . "github.com/rarnu/golcl/lcl/types" 5 | ) 6 | 7 | func SynPythonSyn_Create(owner uintptr) uintptr { 8 | r, _, _ := getLazyProc("SynPythonSyn_Create").Call(owner) 9 | return r 10 | } 11 | 12 | func SynPythonSyn_Free(obj uintptr) { 13 | _, _, _ = getLazyProc("SynPythonSyn_Free").Call(obj) 14 | } 15 | 16 | func SynPythonSyn_StaticClassType() TClass { 17 | r, _, _ := getLazyProc("SynPythonSyn_StaticClassType").Call() 18 | return TClass(r) 19 | } 20 | 21 | func SynPythonSyn_GetEnabled(obj uintptr) bool { 22 | r, _, _ := getLazyProc("SynPythonSyn_GetEnabled").Call(obj) 23 | return DBoolToGoBool(r) 24 | } 25 | 26 | func SynPythonSyn_SetEnabled(obj uintptr, value bool) { 27 | _, _, _ = getLazyProc("SynPythonSyn_SetEnabled").Call(obj, GoBoolToDBool(value)) 28 | } 29 | 30 | func SynPythonSyn_GetCommentAttri(obj uintptr) uintptr { 31 | r, _, _ := getLazyProc("SynPythonSyn_GetCommentAttri").Call(obj) 32 | return r 33 | } 34 | 35 | func SynPythonSyn_GetIdentifierAttri(obj uintptr) uintptr { 36 | r, _, _ := getLazyProc("SynPythonSyn_GetIdentifierAttri").Call(obj) 37 | return r 38 | } 39 | 40 | func SynPythonSyn_GetKeyAttri(obj uintptr) uintptr { 41 | r, _, _ := getLazyProc("SynPythonSyn_GetKeyAttri").Call(obj) 42 | return r 43 | } 44 | 45 | func SynPythonSyn_GetNonKeyAttri(obj uintptr) uintptr { 46 | r, _, _ := getLazyProc("SynPythonSyn_GetNonKeyAttri").Call(obj) 47 | return r 48 | } 49 | 50 | func SynPythonSyn_GetSystemAttri(obj uintptr) uintptr { 51 | r, _, _ := getLazyProc("SynPythonSyn_GetSystemAttri").Call(obj) 52 | return r 53 | } 54 | 55 | func SynPythonSyn_GetNumberAttri(obj uintptr) uintptr { 56 | r, _, _ := getLazyProc("SynPythonSyn_GetNumberAttri").Call(obj) 57 | return r 58 | } 59 | 60 | func SynPythonSyn_GetHexAttri(obj uintptr) uintptr { 61 | r, _, _ := getLazyProc("SynPythonSyn_GetHexAttri").Call(obj) 62 | return r 63 | } 64 | 65 | func SynPythonSyn_GetOctalAttri(obj uintptr) uintptr { 66 | r, _, _ := getLazyProc("SynPythonSyn_GetOctalAttri").Call(obj) 67 | return r 68 | } 69 | 70 | func SynPythonSyn_GetFloatAttri(obj uintptr) uintptr { 71 | r, _, _ := getLazyProc("SynPythonSyn_GetFloatAttri").Call(obj) 72 | return r 73 | } 74 | 75 | func SynPythonSyn_GetSpaceAttri(obj uintptr) uintptr { 76 | r, _, _ := getLazyProc("SynPythonSyn_GetSpaceAttri").Call(obj) 77 | return r 78 | } 79 | 80 | func SynPythonSyn_GetStringAttri(obj uintptr) uintptr { 81 | r, _, _ := getLazyProc("SynPythonSyn_GetStringAttri").Call(obj) 82 | return r 83 | } 84 | 85 | func SynPythonSyn_GetDocStringAttri(obj uintptr) uintptr { 86 | r, _, _ := getLazyProc("SynPythonSyn_GetDocStringAttri").Call(obj) 87 | return r 88 | } 89 | 90 | func SynPythonSyn_GetSymbolAttri(obj uintptr) uintptr { 91 | r, _, _ := getLazyProc("SynPythonSyn_GetSymbolAttri").Call(obj) 92 | return r 93 | } 94 | 95 | func SynPythonSyn_GetErrorAttri(obj uintptr) uintptr { 96 | r, _, _ := getLazyProc("SynPythonSyn_GetErrorAttri").Call(obj) 97 | return r 98 | } 99 | -------------------------------------------------------------------------------- /lcl/win/shell32dll.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | //go:build windows 10 | 11 | package win 12 | 13 | import ( 14 | "syscall" 15 | 16 | "unsafe" 17 | 18 | . "github.com/rarnu/golcl/lcl/types" 19 | ) 20 | 21 | var ( 22 | 23 | // shell32.dll 24 | shell32dll = syscall.NewLazyDLL("shell32.dll") 25 | 26 | _ShellExecute = shell32dll.NewProc("ShellExecuteW") 27 | _ShellExecuteEx = shell32dll.NewProc("ShellExecuteExW") 28 | _ExtractIcon = shell32dll.NewProc("ExtractIconW") 29 | 30 | _SHChangeNotify = shell32dll.NewProc("SHChangeNotify") 31 | _SHGetSpecialFolderPath = shell32dll.NewProc("SHGetSpecialFolderPathW") 32 | _SHGetSpecialFolderLocation = shell32dll.NewProc("SHGetSpecialFolderLocation") 33 | _SHGetPathFromIDList = shell32dll.NewProc("SHGetPathFromIDListW") 34 | _SHGetFileInfo = shell32dll.NewProc("SHGetFileInfoW") 35 | ) 36 | 37 | // ShellExecute 38 | func ShellExecute(hWnd HWND, Operation, FileName, Parameters, Directory string, ShowCmd int32) uintptr { 39 | r, _, _ := _ShellExecute.Call(uintptr(hWnd), CStr(Operation), CStr(FileName), CStr(Parameters), CStr(Directory), uintptr(ShowCmd)) 40 | return r 41 | } 42 | 43 | func ShellExecuteEx(lpExecInfo *TShellExecuteInfo) bool { 44 | r, _, _ := _ShellExecuteEx.Call(uintptr(unsafe.Pointer(lpExecInfo))) 45 | return r != 0 46 | } 47 | 48 | // ExtractIcon 49 | func ExtractIcon(hInst uintptr, lpszExeFileName string, nIconIndex uint32) HICON { 50 | r, _, _ := _ExtractIcon.Call(hInst, CStr(lpszExeFileName), uintptr(nIconIndex)) 51 | return HICON(r) 52 | } 53 | 54 | // SHChangeNotify 55 | func SHChangeNotify(wEventId int32, uFlags uint32, dwItem1, dwItem2 uintptr) { 56 | _SHChangeNotify.Call(uintptr(wEventId), uintptr(uFlags), dwItem1, dwItem2) 57 | } 58 | 59 | // SHGetSpecialFolderPath 60 | func SHGetSpecialFolderPath(hwndOwner HWND, lpszPath *string, nFolder int32, fCreate bool) bool { 61 | buff := make([]uint16, 255) 62 | r, _, _ := _SHGetSpecialFolderPath.Call(uintptr(hwndOwner), uintptr(unsafe.Pointer(&buff[0])), uintptr(nFolder), CBool(fCreate)) 63 | *lpszPath = GoStr(buff) 64 | return r != 0 65 | } 66 | 67 | func SHGetSpecialFolderLocation(hwndOwner HWND, nFolder int32, ppidl **TItemIDList) HResult { 68 | r, _, _ := _SHGetSpecialFolderLocation.Call(uintptr(hwndOwner), uintptr(nFolder), uintptr(unsafe.Pointer(ppidl))) 69 | return HResult(r) 70 | } 71 | 72 | func SHGetPathFromIDList(pidl *TItemIDList) (bool, string) { 73 | szPath := make([]uint16, MAX_PATH) 74 | r, _, _ := _SHGetPathFromIDList.Call(uintptr(unsafe.Pointer(pidl)), uintptr(unsafe.Pointer(&szPath[0]))) 75 | return r != 0, GoStr(szPath) 76 | } 77 | 78 | func SHGetFileInfo(pszPath string, dwFileAttributes uint32, psfi *TSHFileInfo, uFlags uint32) DWORD_PTR { 79 | r, _, _ := _SHGetFileInfo.Call(CStr(pszPath), uintptr(dwFileAttributes), uintptr(unsafe.Pointer(psfi)), uintptr(uFlags)) 80 | return DWORD_PTR(r) 81 | } 82 | -------------------------------------------------------------------------------- /lcl/api/importFuncsCollectionItem.go: -------------------------------------------------------------------------------- 1 | package api 2 | 3 | import ( 4 | . "github.com/rarnu/golcl/lcl/types" 5 | ) 6 | 7 | //--------------------------- TCollectionItem --------------------------- 8 | 9 | func CollectionItem_Create(obj uintptr) uintptr { 10 | ret, _, _ := getLazyProc("CollectionItem_Create").Call(obj) 11 | return ret 12 | } 13 | 14 | func CollectionItem_Free(obj uintptr) { 15 | _, _, _ = getLazyProc("CollectionItem_Free").Call(obj) 16 | } 17 | 18 | func CollectionItem_GetNamePath(obj uintptr) string { 19 | ret, _, _ := getLazyProc("CollectionItem_GetNamePath").Call(obj) 20 | return DStrToGoStr(ret) 21 | } 22 | 23 | func CollectionItem_Assign(obj uintptr, Source uintptr) { 24 | _, _, _ = getLazyProc("CollectionItem_Assign").Call(obj, Source) 25 | } 26 | 27 | func CollectionItem_ClassType(obj uintptr) TClass { 28 | ret, _, _ := getLazyProc("CollectionItem_ClassType").Call(obj) 29 | return TClass(ret) 30 | } 31 | 32 | func CollectionItem_ClassName(obj uintptr) string { 33 | ret, _, _ := getLazyProc("CollectionItem_ClassName").Call(obj) 34 | return DStrToGoStr(ret) 35 | } 36 | 37 | func CollectionItem_InstanceSize(obj uintptr) int32 { 38 | ret, _, _ := getLazyProc("CollectionItem_InstanceSize").Call(obj) 39 | return int32(ret) 40 | } 41 | 42 | func CollectionItem_InheritsFrom(obj uintptr, AClass TClass) bool { 43 | ret, _, _ := getLazyProc("CollectionItem_InheritsFrom").Call(obj, uintptr(AClass)) 44 | return DBoolToGoBool(ret) 45 | } 46 | 47 | func CollectionItem_Equals(obj uintptr, Obj uintptr) bool { 48 | ret, _, _ := getLazyProc("CollectionItem_Equals").Call(obj, Obj) 49 | return DBoolToGoBool(ret) 50 | } 51 | 52 | func CollectionItem_GetHashCode(obj uintptr) int32 { 53 | ret, _, _ := getLazyProc("CollectionItem_GetHashCode").Call(obj) 54 | return int32(ret) 55 | } 56 | 57 | func CollectionItem_ToString(obj uintptr) string { 58 | ret, _, _ := getLazyProc("CollectionItem_ToString").Call(obj) 59 | return DStrToGoStr(ret) 60 | } 61 | 62 | func CollectionItem_GetCollection(obj uintptr) uintptr { 63 | ret, _, _ := getLazyProc("CollectionItem_GetCollection").Call(obj) 64 | return ret 65 | } 66 | 67 | func CollectionItem_SetCollection(obj uintptr, value uintptr) { 68 | _, _, _ = getLazyProc("CollectionItem_SetCollection").Call(obj, value) 69 | } 70 | 71 | func CollectionItem_GetIndex(obj uintptr) int32 { 72 | ret, _, _ := getLazyProc("CollectionItem_GetIndex").Call(obj) 73 | return int32(ret) 74 | } 75 | 76 | func CollectionItem_SetIndex(obj uintptr, value int32) { 77 | _, _, _ = getLazyProc("CollectionItem_SetIndex").Call(obj, uintptr(value)) 78 | } 79 | 80 | func CollectionItem_GetDisplayName(obj uintptr) string { 81 | ret, _, _ := getLazyProc("CollectionItem_GetDisplayName").Call(obj) 82 | return DStrToGoStr(ret) 83 | } 84 | 85 | func CollectionItem_SetDisplayName(obj uintptr, value string) { 86 | _, _, _ = getLazyProc("CollectionItem_SetDisplayName").Call(obj, GoStrToDStr(value)) 87 | } 88 | 89 | func CollectionItem_StaticClassType() TClass { 90 | r, _, _ := getLazyProc("CollectionItem_StaticClassType").Call() 91 | return TClass(r) 92 | } 93 | -------------------------------------------------------------------------------- /lcl/api/importFuncsSeriesPointer.go: -------------------------------------------------------------------------------- 1 | package api 2 | 3 | import ( 4 | . "github.com/rarnu/golcl/lcl/types" 5 | ) 6 | 7 | func SeriesPointer_Create(obj uintptr) uintptr { 8 | ret, _, _ := getLazyProc("SeriesPointer_Create").Call(obj) 9 | return ret 10 | } 11 | 12 | func SeriesPointer_Free(obj uintptr) { 13 | _, _, _ = getLazyProc("SeriesPointer_Free").Call(obj) 14 | } 15 | 16 | func SeriesPointer_StaticClassType() TClass { 17 | ret, _, _ := getLazyProc("SeriesPointer_StaticClassType").Call() 18 | return TClass(ret) 19 | } 20 | 21 | func SeriesPointer_GetBrush(obj uintptr) uintptr { 22 | ret, _, _ := getLazyProc("SeriesPointer_GetBrush").Call(obj) 23 | return ret 24 | } 25 | 26 | func SeriesPointer_SetBrush(obj uintptr, value uintptr) { 27 | _, _, _ = getLazyProc("SeriesPointer_SetBrush").Call(obj, value) 28 | } 29 | 30 | func SeriesPointer_GetHorizSize(obj uintptr) int32 { 31 | ret, _, _ := getLazyProc("SeriesPointer_GetHorizSize").Call(obj) 32 | return int32(ret) 33 | } 34 | 35 | func SeriesPointer_SetHorizSize(obj uintptr, value int32) { 36 | _, _, _ = getLazyProc("SeriesPointer_SetHorizSize").Call(obj, uintptr(value)) 37 | } 38 | 39 | func SeriesPointer_GetOverrideColor(obj uintptr) TOverrideColors { 40 | ret, _, _ := getLazyProc("SeriesPointer_GetOverrideColor").Call(obj) 41 | return TOverrideColors(ret) 42 | } 43 | 44 | func SeriesPointer_SetOverrideColor(obj uintptr, value TOverrideColors) { 45 | _, _, _ = getLazyProc("SeriesPointer_SetOverrideColor").Call(obj, uintptr(value)) 46 | } 47 | 48 | func SeriesPointer_GetPen(obj uintptr) uintptr { 49 | ret, _, _ := getLazyProc("SeriesPointer_GetPen").Call(obj) 50 | return ret 51 | } 52 | 53 | func SeriesPointer_SetPen(obj uintptr, value uintptr) { 54 | _, _, _ = getLazyProc("SeriesPointer_SetPen").Call(obj, value) 55 | } 56 | 57 | func SeriesPointer_GetStyle(obj uintptr) TSeriesPointerStyle { 58 | ret, _, _ := getLazyProc("SeriesPointer_GetStyle").Call(obj) 59 | return TSeriesPointerStyle(ret) // convert from TSeriesPointerStyle 60 | } 61 | 62 | func SeriesPointer_SetStyle(obj uintptr, value TSeriesPointerStyle) { 63 | _, _, _ = getLazyProc("SeriesPointer_SetStyle").Call(obj, uintptr(value)) 64 | } 65 | 66 | func SeriesPointer_GetVertSize(obj uintptr) int32 { 67 | ret, _, _ := getLazyProc("SeriesPointer_GetVertSize").Call(obj) 68 | return int32(ret) 69 | } 70 | 71 | func SeriesPointer_SetVertSize(obj uintptr, value int32) { 72 | _, _, _ = getLazyProc("SeriesPointer_SetVertSize").Call(obj, uintptr(value)) 73 | } 74 | 75 | func SeriesPointer_GetVisible(obj uintptr) bool { 76 | ret, _, _ := getLazyProc("SeriesPointer_GetVisible").Call(obj) 77 | return DBoolToGoBool(ret) 78 | } 79 | 80 | func SeriesPointer_SetVisible(obj uintptr, value bool) { 81 | _, _, _ = getLazyProc("SeriesPointer_SetVisible").Call(obj, GoBoolToDBool(value)) 82 | } 83 | 84 | func SeriesPointer_GetOwner(obj uintptr) uintptr { 85 | ret, _, _ := getLazyProc("SeriesPointer_GetOwner").Call(obj) 86 | return ret 87 | } 88 | 89 | func SeriesPointer_SetOwner(obj uintptr, AOwner uintptr) { 90 | _, _, _ = getLazyProc("SeriesPointer_SetOwner").Call(obj, AOwner) 91 | } 92 | -------------------------------------------------------------------------------- /lcl/api/importFuncsBrush.go: -------------------------------------------------------------------------------- 1 | package api 2 | 3 | import ( 4 | . "github.com/rarnu/golcl/lcl/types" 5 | ) 6 | 7 | //--------------------------- TBrush --------------------------- 8 | 9 | func Brush_Create() uintptr { 10 | ret, _, _ := getLazyProc("Brush_Create").Call() 11 | return ret 12 | } 13 | 14 | func Brush_Free(obj uintptr) { 15 | _, _, _ = getLazyProc("Brush_Free").Call(obj) 16 | } 17 | 18 | func Brush_Assign(obj uintptr, Source uintptr) { 19 | _, _, _ = getLazyProc("Brush_Assign").Call(obj, Source) 20 | } 21 | 22 | func Brush_GetNamePath(obj uintptr) string { 23 | ret, _, _ := getLazyProc("Brush_GetNamePath").Call(obj) 24 | return DStrToGoStr(ret) 25 | } 26 | 27 | func Brush_ClassType(obj uintptr) TClass { 28 | ret, _, _ := getLazyProc("Brush_ClassType").Call(obj) 29 | return TClass(ret) 30 | } 31 | 32 | func Brush_ClassName(obj uintptr) string { 33 | ret, _, _ := getLazyProc("Brush_ClassName").Call(obj) 34 | return DStrToGoStr(ret) 35 | } 36 | 37 | func Brush_InstanceSize(obj uintptr) int32 { 38 | ret, _, _ := getLazyProc("Brush_InstanceSize").Call(obj) 39 | return int32(ret) 40 | } 41 | 42 | func Brush_InheritsFrom(obj uintptr, AClass TClass) bool { 43 | ret, _, _ := getLazyProc("Brush_InheritsFrom").Call(obj, uintptr(AClass)) 44 | return DBoolToGoBool(ret) 45 | } 46 | 47 | func Brush_Equals(obj uintptr, Obj uintptr) bool { 48 | ret, _, _ := getLazyProc("Brush_Equals").Call(obj, Obj) 49 | return DBoolToGoBool(ret) 50 | } 51 | 52 | func Brush_GetHashCode(obj uintptr) int32 { 53 | ret, _, _ := getLazyProc("Brush_GetHashCode").Call(obj) 54 | return int32(ret) 55 | } 56 | 57 | func Brush_ToString(obj uintptr) string { 58 | ret, _, _ := getLazyProc("Brush_ToString").Call(obj) 59 | return DStrToGoStr(ret) 60 | } 61 | 62 | func Brush_GetBitmap(obj uintptr) uintptr { 63 | ret, _, _ := getLazyProc("Brush_GetBitmap").Call(obj) 64 | return ret 65 | } 66 | 67 | func Brush_SetBitmap(obj uintptr, value uintptr) { 68 | _, _, _ = getLazyProc("Brush_SetBitmap").Call(obj, value) 69 | } 70 | 71 | func Brush_GetHandle(obj uintptr) HBRUSH { 72 | ret, _, _ := getLazyProc("Brush_GetHandle").Call(obj) 73 | return ret 74 | } 75 | 76 | func Brush_SetHandle(obj uintptr, value HBRUSH) { 77 | _, _, _ = getLazyProc("Brush_SetHandle").Call(obj, value) 78 | } 79 | 80 | func Brush_GetColor(obj uintptr) TColor { 81 | ret, _, _ := getLazyProc("Brush_GetColor").Call(obj) 82 | return TColor(ret) 83 | } 84 | 85 | func Brush_SetColor(obj uintptr, value TColor) { 86 | _, _, _ = getLazyProc("Brush_SetColor").Call(obj, uintptr(value)) 87 | } 88 | 89 | func Brush_GetStyle(obj uintptr) TBrushStyle { 90 | ret, _, _ := getLazyProc("Brush_GetStyle").Call(obj) 91 | return TBrushStyle(ret) 92 | } 93 | 94 | func Brush_SetStyle(obj uintptr, value TBrushStyle) { 95 | _, _, _ = getLazyProc("Brush_SetStyle").Call(obj, uintptr(value)) 96 | } 97 | 98 | func Brush_SetOnChange(obj uintptr, fn any) { 99 | _, _, _ = getLazyProc("Brush_SetOnChange").Call(obj, addEventToMap(obj, fn)) 100 | } 101 | 102 | func Brush_StaticClassType() TClass { 103 | r, _, _ := getLazyProc("Brush_StaticClassType").Call() 104 | return TClass(r) 105 | } 106 | -------------------------------------------------------------------------------- /lcl/win/structs.go: -------------------------------------------------------------------------------- 1 | //---------------------------------------- 2 | // 3 | // Copyright © ying32. All Rights Reserved. 4 | // 5 | // Licensed under Apache License 2.0 6 | // 7 | //---------------------------------------- 8 | 9 | //go:build windows 10 | 11 | package win 12 | 13 | import . "github.com/rarnu/golcl/lcl/types" 14 | 15 | type TRGBQuad struct { 16 | RgbBlue uint8 17 | RgbGreen uint8 18 | RgbRed uint8 19 | RgbReserved uint8 20 | } 21 | 22 | type TBitmapInfoHeader struct { 23 | BiSize uint32 24 | BiWidth uint32 25 | BiHeight uint32 26 | BiPlanes uint16 27 | BiBitCount uint16 28 | BiCompression uint32 29 | BiSizeImage uint32 30 | BiXPelsPerMeter uint32 31 | BiYPelsPerMeter uint32 32 | BiClrUsed uint32 33 | BiClrImportant uint32 34 | } 35 | 36 | type TBitmapInfo struct { 37 | BmiHeader TBitmapInfoHeader 38 | BmiColors [1]TRGBQuad 39 | } 40 | 41 | type TBlendFunction struct { 42 | BlendOp uint8 43 | BlendFlags uint8 44 | SourceConstantAlpha uint8 45 | AlphaFormat uint8 46 | } 47 | 48 | type TSystemInfo struct { 49 | 50 | //0: ( 51 | //dwOemId: DWORD); 52 | //1: ( 53 | ProcessorArchitecture uint16 54 | Reserved uint16 55 | 56 | PageSize uint32 57 | MinimumApplicationAddress uintptr 58 | MaximumApplicationAddress uintptr 59 | ActiveProcessorMask uintptr 60 | NumberOfProcessors uint32 61 | ProcessorType uint32 62 | AllocationGranularity uint32 63 | ProcessorLevel uint16 64 | ProcessorRevision uint16 65 | } 66 | 67 | type TSecurityAttributes struct { 68 | nLength uint32 69 | lpSecurityDescriptor uintptr 70 | bInheritHandle bool // BOOL 71 | } 72 | 73 | type TSHItemID struct { 74 | Cb uint16 // Size of the ID (including cb itself) 75 | AbID [1]byte // The item ID (variable length) 76 | } 77 | 78 | type TItemIDList struct { 79 | Mkid TSHItemID 80 | } 81 | 82 | // ShellExecuteEx 83 | type TShellExecuteInfo struct { 84 | CbSize uint32 85 | FMask uint32 86 | Wnd HWND 87 | LpVerb LPCWSTR 88 | LpFile LPCWSTR 89 | LpParameters LPCWSTR 90 | LpDirectory LPCWSTR 91 | NShow int32 92 | HInstApp HINST 93 | // Optional fields 94 | LpIDList uintptr 95 | LpClass LPCWSTR 96 | HkeyClass HKEY 97 | DwHotKey uint32 98 | 99 | // 0: ( 100 | // HICON 101 | // 1: ( 102 | HIcon_hMonitor uintptr 103 | 104 | HProcess uintptr 105 | } 106 | 107 | type TMemoryBasicInformation struct { 108 | BaseAddress uintptr 109 | AllocationBase uintptr 110 | AllocationProtect uint32 111 | RegionSize SIZE_T 112 | State uint32 113 | Protect uint32 114 | Type_9 uint32 115 | } 116 | 117 | type TSHFileInfo struct { 118 | HIcon HICON /* out: icon */ 119 | IIcon Integer /* out: icon index */ 120 | DwAttributes DWORD /* out: SFGAO_ flags */ 121 | SzDisplayName [MAX_PATH]uint16 /* out: display name (or path) */ 122 | SzTypeName [80]uint16 /* out: type name */ 123 | } 124 | -------------------------------------------------------------------------------- /lcl/api/importFuncsSynXmlSyn.go: -------------------------------------------------------------------------------- 1 | package api 2 | 3 | import ( 4 | . "github.com/rarnu/golcl/lcl/types" 5 | ) 6 | 7 | func SynXMLSyn_Create(owner uintptr) uintptr { 8 | r, _, _ := getLazyProc("SynXMLSyn_Create").Call(owner) 9 | return r 10 | } 11 | 12 | func SynXMLSyn_Free(obj uintptr) { 13 | _, _, _ = getLazyProc("SynXMLSyn_Free").Call(obj) 14 | } 15 | 16 | func SynXMLSyn_StaticClassType() TClass { 17 | r, _, _ := getLazyProc("SynXMLSyn_StaticClassType").Call() 18 | return TClass(r) 19 | } 20 | 21 | func SynXMLSyn_GetEnabled(obj uintptr) bool { 22 | r, _, _ := getLazyProc("SynXMLSyn_GetEnabled").Call(obj) 23 | return DBoolToGoBool(r) 24 | } 25 | 26 | func SynXMLSyn_SetEnabled(obj uintptr, value bool) { 27 | _, _, _ = getLazyProc("SynXMLSyn_SetEnabled").Call(obj, GoBoolToDBool(value)) 28 | } 29 | 30 | func SynXMLSyn_GetElementAttri(obj uintptr) uintptr { 31 | r, _, _ := getLazyProc("SynXMLSyn_GetElementAttri").Call(obj) 32 | return r 33 | } 34 | 35 | func SynXMLSyn_GetAttributeAttri(obj uintptr) uintptr { 36 | r, _, _ := getLazyProc("SynXMLSyn_GetAttributeAttri").Call(obj) 37 | return r 38 | } 39 | 40 | func SynXMLSyn_GetNamespaceAttributeAttri(obj uintptr) uintptr { 41 | r, _, _ := getLazyProc("SynXMLSyn_GetNamespaceAttributeAttri").Call(obj) 42 | return r 43 | } 44 | 45 | func SynXMLSyn_GetAttributeValueAttri(obj uintptr) uintptr { 46 | r, _, _ := getLazyProc("SynXMLSyn_GetAttributeValueAttri").Call(obj) 47 | return r 48 | } 49 | 50 | func SynXMLSyn_GetNamespaceAttributeValueAttri(obj uintptr) uintptr { 51 | r, _, _ := getLazyProc("SynXMLSyn_GetNamespaceAttributeValueAttri").Call(obj) 52 | return r 53 | } 54 | 55 | func SynXMLSyn_GetTextAttri(obj uintptr) uintptr { 56 | r, _, _ := getLazyProc("SynXMLSyn_GetTextAttri").Call(obj) 57 | return r 58 | } 59 | 60 | func SynXMLSyn_GetCDATAAttri(obj uintptr) uintptr { 61 | r, _, _ := getLazyProc("SynXMLSyn_GetCDATAAttri").Call(obj) 62 | return r 63 | } 64 | 65 | func SynXMLSyn_GetEntityRefAttri(obj uintptr) uintptr { 66 | r, _, _ := getLazyProc("SynXMLSyn_GetEntityRefAttri").Call(obj) 67 | return r 68 | } 69 | 70 | func SynXMLSyn_GetProcessingInstructionAttri(obj uintptr) uintptr { 71 | r, _, _ := getLazyProc("SynXMLSyn_GetProcessingInstructionAttri").Call(obj) 72 | return r 73 | } 74 | 75 | func SynXMLSyn_GetCommentAttri(obj uintptr) uintptr { 76 | r, _, _ := getLazyProc("SynXMLSyn_GetCommentAttri").Call(obj) 77 | return r 78 | } 79 | 80 | func SynXMLSyn_GetDocTypeAttri(obj uintptr) uintptr { 81 | r, _, _ := getLazyProc("SynXMLSyn_GetDocTypeAttri").Call(obj) 82 | return r 83 | } 84 | 85 | func SynXMLSyn_GetSpaceAttri(obj uintptr) uintptr { 86 | r, _, _ := getLazyProc("SynXMLSyn_GetSpaceAttri").Call(obj) 87 | return r 88 | } 89 | 90 | func SynXMLSyn_GetSymbolAttri(obj uintptr) uintptr { 91 | r, _, _ := getLazyProc("SynXMLSyn_GetSymbolAttri").Call(obj) 92 | return r 93 | } 94 | 95 | func SynXMLSyn_GetWantBracesParsed(obj uintptr) bool { 96 | r, _, _ := getLazyProc("SynXMLSyn_GetWantBracesParsed").Call(obj) 97 | return DBoolToGoBool(r) 98 | } 99 | 100 | func SynXMLSyn_SetWantBracesParsed(obj uintptr, value bool) { 101 | _, _, _ = getLazyProc("SynXMLSyn_SetWantBracesParsed").Call(obj, GoBoolToDBool(value)) 102 | } 103 | -------------------------------------------------------------------------------- /lcl/syncsssyn.go: -------------------------------------------------------------------------------- 1 | package lcl 2 | 3 | import ( 4 | . "github.com/rarnu/golcl/lcl/api" 5 | . "github.com/rarnu/golcl/lcl/types" 6 | "unsafe" 7 | ) 8 | 9 | type TSynCssSyn struct { 10 | TSynCustomHighlighter 11 | instance uintptr 12 | ptr unsafe.Pointer 13 | } 14 | 15 | func AsSynCssSyn(obj any) *TSynCssSyn { 16 | instance, ptr := getInstance(obj) 17 | if instance == 0 { 18 | return nil 19 | } 20 | return &TSynCssSyn{instance: instance, ptr: ptr} 21 | } 22 | 23 | func SynCssSynFromInst(inst uintptr) *TSynCssSyn { 24 | return AsSynCssSyn(inst) 25 | } 26 | 27 | func SynCssSynFromObj(obj IObject) *TSynCssSyn { 28 | return AsSynCssSyn(obj) 29 | } 30 | 31 | func SynCssSynFromUnsafePointer(ptr unsafe.Pointer) *TSynCssSyn { 32 | return AsSynCssSyn(ptr) 33 | } 34 | 35 | func (s *TSynCssSyn) Instance() uintptr { 36 | return s.instance 37 | } 38 | 39 | func (s *TSynCssSyn) UnsafeAddr() unsafe.Pointer { 40 | return s.ptr 41 | } 42 | 43 | func (s *TSynCssSyn) IsValid() bool { 44 | return s.instance != 0 45 | } 46 | 47 | func (s *TSynCssSyn) Is() TIs { 48 | return TIs(s.instance) 49 | } 50 | 51 | func TSynCssSynClass() TClass { 52 | return SynCssSyn_StaticClassType() 53 | } 54 | 55 | func NewSynCssSyn(owner IComponent) *TSynCssSyn { 56 | s := new(TSynCssSyn) 57 | s.instance = SynCssSyn_Create(CheckPtr(owner)) 58 | s.ptr = unsafe.Pointer(s.instance) 59 | return s 60 | } 61 | 62 | func (s *TSynCssSyn) Free() { 63 | if s.instance != 0 { 64 | SynCssSyn_Free(s.instance) 65 | s.instance, s.ptr = 0, nullptr 66 | } 67 | } 68 | 69 | func (s *TSynCssSyn) GetEnabled() bool { 70 | return SynCssSyn_GetEnabled(s.instance) 71 | } 72 | 73 | func (s *TSynCssSyn) SetEnabled(value bool) { 74 | SynCssSyn_SetEnabled(s.instance, value) 75 | } 76 | 77 | func (s *TSynCssSyn) GetCommentAttri() *TSynHighlighterAttributes { 78 | return AsSynHighlighterAttributes(SynCssSyn_GetCommentAttri(s.instance)) 79 | } 80 | 81 | func (s *TSynCssSyn) GetIdentifierAttri() *TSynHighlighterAttributes { 82 | return AsSynHighlighterAttributes(SynCssSyn_GetIdentifierAttri(s.instance)) 83 | } 84 | 85 | func (s *TSynCssSyn) GetKeyAttri() *TSynHighlighterAttributes { 86 | return AsSynHighlighterAttributes(SynCssSyn_GetKeyAttri(s.instance)) 87 | } 88 | 89 | func (s *TSynCssSyn) GetNumberAttri() *TSynHighlighterAttributes { 90 | return AsSynHighlighterAttributes(SynCssSyn_GetNumberAttri(s.instance)) 91 | } 92 | 93 | func (s *TSynCssSyn) GetSpaceAttri() *TSynHighlighterAttributes { 94 | return AsSynHighlighterAttributes(SynCssSyn_GetSpaceAttri(s.instance)) 95 | } 96 | 97 | func (s *TSynCssSyn) GetStringAttri() *TSynHighlighterAttributes { 98 | return AsSynHighlighterAttributes(SynCssSyn_GetStringAttri(s.instance)) 99 | } 100 | 101 | func (s *TSynCssSyn) GetSymbolAttri() *TSynHighlighterAttributes { 102 | return AsSynHighlighterAttributes(SynCssSyn_GetSymbolAttri(s.instance)) 103 | } 104 | 105 | func (s *TSynCssSyn) GetMeasurementUnitAttri() *TSynHighlighterAttributes { 106 | return AsSynHighlighterAttributes(SynCssSyn_GetMeasurementUnitAttri(s.instance)) 107 | } 108 | 109 | func (s *TSynCssSyn) GetSelectorAttri() *TSynHighlighterAttributes { 110 | return AsSynHighlighterAttributes(SynCssSyn_GetSelectorAttri(s.instance)) 111 | } 112 | -------------------------------------------------------------------------------- /lcl/synphpsyn.go: -------------------------------------------------------------------------------- 1 | package lcl 2 | 3 | import ( 4 | . "github.com/rarnu/golcl/lcl/api" 5 | . "github.com/rarnu/golcl/lcl/types" 6 | "unsafe" 7 | ) 8 | 9 | type TSynPHPSyn struct { 10 | TSynCustomHighlighter 11 | instance uintptr 12 | ptr unsafe.Pointer 13 | } 14 | 15 | func AsSynPHPSyn(obj any) *TSynPHPSyn { 16 | instance, ptr := getInstance(obj) 17 | if instance == 0 { 18 | return nil 19 | } 20 | return &TSynPHPSyn{instance: instance, ptr: ptr} 21 | } 22 | 23 | func SynPHPSynFromInst(inst uintptr) *TSynPHPSyn { 24 | return AsSynPHPSyn(inst) 25 | } 26 | 27 | func SynPHPSynFromObj(obj IObject) *TSynPHPSyn { 28 | return AsSynPHPSyn(obj) 29 | } 30 | 31 | func SynPHPSynFromUnsafePointer(ptr unsafe.Pointer) *TSynPHPSyn { 32 | return AsSynPHPSyn(ptr) 33 | } 34 | 35 | func (s *TSynPHPSyn) Instance() uintptr { 36 | return s.instance 37 | } 38 | 39 | func (s *TSynPHPSyn) UnsafeAddr() unsafe.Pointer { 40 | return s.ptr 41 | } 42 | 43 | func (s *TSynPHPSyn) IsValid() bool { 44 | return s.instance != 0 45 | } 46 | 47 | func (s *TSynPHPSyn) Is() TIs { 48 | return TIs(s.instance) 49 | } 50 | 51 | func TSynPHPSynClass() TClass { 52 | return SynPHPSyn_StaticClassType() 53 | } 54 | 55 | func NewSynPHPSyn(owner IComponent) *TSynPHPSyn { 56 | s := new(TSynPHPSyn) 57 | s.instance = SynPHPSyn_Create(CheckPtr(owner)) 58 | s.ptr = unsafe.Pointer(s.instance) 59 | return s 60 | } 61 | 62 | func (s *TSynPHPSyn) Free() { 63 | if s.instance != 0 { 64 | SynPHPSyn_Free(s.instance) 65 | s.instance, s.ptr = 0, nullptr 66 | } 67 | } 68 | 69 | func (s *TSynPHPSyn) GetEnabled() bool { 70 | return SynPHPSyn_GetEnabled(s.instance) 71 | } 72 | 73 | func (s *TSynPHPSyn) SetEnabled(value bool) { 74 | SynPHPSyn_SetEnabled(s.instance, value) 75 | } 76 | 77 | func (s *TSynPHPSyn) GetCommentAttri() *TSynHighlighterAttributes { 78 | return AsSynHighlighterAttributes(SynPHPSyn_GetCommentAttri(s.instance)) 79 | } 80 | 81 | func (s *TSynPHPSyn) GetIdentifierAttri() *TSynHighlighterAttributes { 82 | return AsSynHighlighterAttributes(SynPHPSyn_GetIdentifierAttri(s.instance)) 83 | } 84 | 85 | func (s *TSynPHPSyn) GetInvalidSymbolAttri() *TSynHighlighterAttributes { 86 | return AsSynHighlighterAttributes(SynPHPSyn_GetInvalidSymbolAttri(s.instance)) 87 | } 88 | 89 | func (s *TSynPHPSyn) GetKeyAttri() *TSynHighlighterAttributes { 90 | return AsSynHighlighterAttributes(SynPHPSyn_GetKeyAttri(s.instance)) 91 | } 92 | 93 | func (s *TSynPHPSyn) GetNumberAttri() *TSynHighlighterAttributes { 94 | return AsSynHighlighterAttributes(SynPHPSyn_GetNumberAttri(s.instance)) 95 | } 96 | 97 | func (s *TSynPHPSyn) GetSpaceAttri() *TSynHighlighterAttributes { 98 | return AsSynHighlighterAttributes(SynPHPSyn_GetSpaceAttri(s.instance)) 99 | } 100 | 101 | func (s *TSynPHPSyn) GetStringAttri() *TSynHighlighterAttributes { 102 | return AsSynHighlighterAttributes(SynPHPSyn_GetStringAttri(s.instance)) 103 | } 104 | 105 | func (s *TSynPHPSyn) GetSymbolAttri() *TSynHighlighterAttributes { 106 | return AsSynHighlighterAttributes(SynPHPSyn_GetSymbolAttri(s.instance)) 107 | } 108 | 109 | func (s *TSynPHPSyn) GetVariableAttri() *TSynHighlighterAttributes { 110 | return AsSynHighlighterAttributes(SynPHPSyn_GetVariableAttri(s.instance)) 111 | } 112 | -------------------------------------------------------------------------------- /lcl/api/importFuncsChartSeriesLegend.go: -------------------------------------------------------------------------------- 1 | package api 2 | 3 | import ( 4 | . "github.com/rarnu/golcl/lcl/types" 5 | ) 6 | 7 | func ChartSeriesLegend_Create(obj uintptr) uintptr { 8 | ret, _, _ := getLazyProc("ChartSeriesLegend_Create").Call(obj) 9 | return ret 10 | } 11 | 12 | func ChartSeriesLegend_Free(obj uintptr) { 13 | _, _, _ = getLazyProc("ChartSeriesLegend_Free").Call(obj) 14 | } 15 | 16 | func ChartSeriesLegend_StaticClassType() TClass { 17 | ret, _, _ := getLazyProc("ChartSeriesLegend_StaticClassType").Call() 18 | return TClass(ret) 19 | } 20 | 21 | func ChartSeriesLegend_GetFormat(obj uintptr) string { 22 | ret, _, _ := getLazyProc("ChartSeriesLegend_GetFormat").Call(obj) 23 | return DStrToGoStr(ret) 24 | } 25 | 26 | func ChartSeriesLegend_SetFormat(obj uintptr, value string) { 27 | _, _, _ = getLazyProc("ChartSeriesLegend_SetFormat").Call(obj, GoStrToDStr(value)) 28 | } 29 | 30 | func ChartSeriesLegend_GetGroupIndex(obj uintptr) int32 { 31 | ret, _, _ := getLazyProc("ChartSeriesLegend_GetGroupIndex").Call(obj) 32 | return int32(ret) 33 | } 34 | 35 | func ChartSeriesLegend_SetGroupIndex(obj uintptr, value int32) { 36 | _, _, _ = getLazyProc("ChartSeriesLegend_SetGroupIndex").Call(obj, uintptr(value)) 37 | } 38 | 39 | func ChartSeriesLegend_GetMultiplicity(obj uintptr) TLegendMultiplicity { 40 | ret, _, _ := getLazyProc("ChartSeriesLegend_GetMultiplicity").Call(obj) 41 | return TLegendMultiplicity(ret) 42 | } 43 | 44 | func ChartSeriesLegend_SetMultiplicity(obj uintptr, value TLegendMultiplicity) { 45 | _, _, _ = getLazyProc("ChartSeriesLegend_SetMultiplicity").Call(obj, uintptr(value)) 46 | } 47 | 48 | func ChartSeriesLegend_GetOrder(obj uintptr) int32 { 49 | ret, _, _ := getLazyProc("ChartSeriesLegend_GetOrder").Call(obj) 50 | return int32(ret) 51 | } 52 | 53 | func ChartSeriesLegend_SetOrder(obj uintptr, value int32) { 54 | _, _, _ = getLazyProc("ChartSeriesLegend_SetOrder").Call(obj, uintptr(value)) 55 | } 56 | 57 | func ChartSeriesLegend_GetTextFormat(obj uintptr) TChartTextFormat { 58 | ret, _, _ := getLazyProc("ChartSeriesLegend_GetTextFormat").Call(obj) 59 | return TChartTextFormat(ret) 60 | } 61 | 62 | func ChartSeriesLegend_SetTextFormat(obj uintptr, value TChartTextFormat) { 63 | _, _, _ = getLazyProc("ChartSeriesLegend_SetTextFormat").Call(obj, uintptr(value)) 64 | } 65 | 66 | func ChartSeriesLegend_GetUserItemsCount(obj uintptr) int32 { 67 | ret, _, _ := getLazyProc("ChartSeriesLegend_GetUserItemsCount").Call(obj) 68 | return int32(ret) 69 | } 70 | 71 | func ChartSeriesLegend_SetUserItemsCount(obj uintptr, value int32) { 72 | _, _, _ = getLazyProc("ChartSeriesLegend_SetUserItemsCount").Call(obj, uintptr(value)) 73 | } 74 | 75 | func ChartSeriesLegend_GetVisible(obj uintptr) bool { 76 | ret, _, _ := getLazyProc("ChartSeriesLegend_GetVisible").Call(obj) 77 | return DBoolToGoBool(ret) 78 | } 79 | 80 | func ChartSeriesLegend_SetVisible(obj uintptr, value bool) { 81 | _, _, _ = getLazyProc("ChartSeriesLegend_SetVisible").Call(obj, GoBoolToDBool(value)) 82 | } 83 | 84 | func ChartSeriesLegend_GetOwner(obj uintptr) uintptr { 85 | ret, _, _ := getLazyProc("ChartSeriesLegend_GetOwner").Call(obj) 86 | return ret 87 | } 88 | 89 | func ChartSeriesLegend_SetOwner(obj uintptr, AOwner uintptr) { 90 | _, _, _ = getLazyProc("ChartSeriesLegend_SetOwner").Call(obj, AOwner) 91 | } 92 | -------------------------------------------------------------------------------- /dylib/dylib_windows.go: -------------------------------------------------------------------------------- 1 | package dylib 2 | 3 | import ( 4 | "fmt" 5 | "strconv" 6 | "syscall" 7 | ) 8 | 9 | type LazyDLL struct { 10 | *syscall.LazyDLL 11 | // 加了异常处理的 12 | mySyscall *syscall.LazyProc 13 | } 14 | 15 | func NewLazyDLL(name string) *LazyDLL { 16 | l := new(LazyDLL) 17 | l.LazyDLL = syscall.NewLazyDLL(name) 18 | if err := l.Load(); err != nil { 19 | return l 20 | } 21 | // 导入调用的, 实现一个动态调用call的,主要是为了解决异常问题 22 | l.mySyscall = l.LazyDLL.NewProc("MySyscall") 23 | if l.mySyscall.Find() != nil { 24 | l.mySyscall = nil 25 | } 26 | return l 27 | } 28 | 29 | // 定义一个相同的 30 | type LazyProc struct { 31 | lzProc *syscall.LazyProc 32 | lzdll *LazyDLL 33 | } 34 | 35 | func (d *LazyDLL) NewProc(name string) *LazyProc { 36 | l := new(LazyProc) 37 | l.lzProc = d.LazyDLL.NewProc(name) 38 | l.lzdll = d 39 | return l 40 | } 41 | 42 | func (d *LazyDLL) Close() { 43 | if d.Handle() != 0 { 44 | syscall.FreeLibrary(syscall.Handle(d.Handle())) 45 | } 46 | } 47 | 48 | func (d *LazyDLL) call(proc *LazyProc, a ...uintptr) (r1, r2 uintptr, lastErr error) { 49 | // 没到找到我封装的那个系统函数,就使用原始的 50 | if d.mySyscall == nil { 51 | return proc.CallOriginal(a...) 52 | } 53 | err := proc.Find() 54 | if err != nil { 55 | fmt.Println("proc \"" + proc.lzProc.Name + "\" not find.") 56 | return 0, 0, syscall.EINVAL 57 | } 58 | addr := proc.Addr() 59 | if addr != 0 { 60 | pLen := uintptr(len(a)) 61 | switch pLen { 62 | case 0: 63 | return d.mySyscall.Call(addr, pLen) 64 | case 1: 65 | return d.mySyscall.Call(addr, pLen, a[0]) 66 | case 2: 67 | return d.mySyscall.Call(addr, pLen, a[0], a[1]) 68 | case 3: 69 | return d.mySyscall.Call(addr, pLen, a[0], a[1], a[2]) 70 | case 4: 71 | return d.mySyscall.Call(addr, pLen, a[0], a[1], a[2], a[3]) 72 | case 5: 73 | return d.mySyscall.Call(addr, pLen, a[0], a[1], a[2], a[3], a[4]) 74 | case 6: 75 | return d.mySyscall.Call(addr, pLen, a[0], a[1], a[2], a[3], a[4], a[5]) 76 | case 7: 77 | return d.mySyscall.Call(addr, pLen, a[0], a[1], a[2], a[3], a[4], a[5], a[6]) 78 | case 8: 79 | return d.mySyscall.Call(addr, pLen, a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7]) 80 | case 9: 81 | return d.mySyscall.Call(addr, pLen, a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8]) 82 | case 10: 83 | return d.mySyscall.Call(addr, pLen, a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9]) 84 | case 11: 85 | return d.mySyscall.Call(addr, pLen, a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9], a[10]) 86 | case 12: 87 | return d.mySyscall.Call(addr, pLen, a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9], a[10], a[11]) 88 | default: 89 | panic("Call " + proc.lzProc.Name + " with too many arguments " + strconv.Itoa(len(a)) + ".") 90 | } 91 | } 92 | return 0, 0, syscall.EINVAL 93 | } 94 | 95 | func (p *LazyProc) Addr() uintptr { 96 | return p.lzProc.Addr() 97 | } 98 | 99 | func (p *LazyProc) Find() error { 100 | return p.lzProc.Find() 101 | } 102 | 103 | func (p *LazyProc) Call(a ...uintptr) (r1, r2 uintptr, lastErr error) { 104 | return p.lzdll.call(p, a...) 105 | } 106 | 107 | func (p *LazyProc) CallOriginal(a ...uintptr) (r1, r2 uintptr, lastErr error) { 108 | return p.lzProc.Call(a...) 109 | } 110 | -------------------------------------------------------------------------------- /lcl/api/importFuncsMonitor.go: -------------------------------------------------------------------------------- 1 | package api 2 | 3 | import ( 4 | . "github.com/rarnu/golcl/lcl/types" 5 | "unsafe" 6 | ) 7 | 8 | //--------------------------- TMonitor --------------------------- 9 | 10 | func Monitor_Create() uintptr { 11 | ret, _, _ := getLazyProc("Monitor_Create").Call() 12 | return ret 13 | } 14 | 15 | func Monitor_Free(obj uintptr) { 16 | _, _, _ = getLazyProc("Monitor_Free").Call(obj) 17 | } 18 | 19 | func Monitor_ClassType(obj uintptr) TClass { 20 | ret, _, _ := getLazyProc("Monitor_ClassType").Call(obj) 21 | return TClass(ret) 22 | } 23 | 24 | func Monitor_ClassName(obj uintptr) string { 25 | ret, _, _ := getLazyProc("Monitor_ClassName").Call(obj) 26 | return DStrToGoStr(ret) 27 | } 28 | 29 | func Monitor_InstanceSize(obj uintptr) int32 { 30 | ret, _, _ := getLazyProc("Monitor_InstanceSize").Call(obj) 31 | return int32(ret) 32 | } 33 | 34 | func Monitor_InheritsFrom(obj uintptr, AClass TClass) bool { 35 | ret, _, _ := getLazyProc("Monitor_InheritsFrom").Call(obj, uintptr(AClass)) 36 | return DBoolToGoBool(ret) 37 | } 38 | 39 | func Monitor_Equals(obj uintptr, Obj uintptr) bool { 40 | ret, _, _ := getLazyProc("Monitor_Equals").Call(obj, Obj) 41 | return DBoolToGoBool(ret) 42 | } 43 | 44 | func Monitor_GetHashCode(obj uintptr) int32 { 45 | ret, _, _ := getLazyProc("Monitor_GetHashCode").Call(obj) 46 | return int32(ret) 47 | } 48 | 49 | func Monitor_ToString(obj uintptr) string { 50 | ret, _, _ := getLazyProc("Monitor_ToString").Call(obj) 51 | return DStrToGoStr(ret) 52 | } 53 | 54 | func Monitor_GetHandle(obj uintptr) HMONITOR { 55 | ret, _, _ := getLazyProc("Monitor_GetHandle").Call(obj) 56 | return ret 57 | } 58 | 59 | func Monitor_GetMonitorNum(obj uintptr) int32 { 60 | ret, _, _ := getLazyProc("Monitor_GetMonitorNum").Call(obj) 61 | return int32(ret) 62 | } 63 | 64 | func Monitor_GetLeft(obj uintptr) int32 { 65 | ret, _, _ := getLazyProc("Monitor_GetLeft").Call(obj) 66 | return int32(ret) 67 | } 68 | 69 | func Monitor_GetHeight(obj uintptr) int32 { 70 | ret, _, _ := getLazyProc("Monitor_GetHeight").Call(obj) 71 | return int32(ret) 72 | } 73 | 74 | func Monitor_GetTop(obj uintptr) int32 { 75 | ret, _, _ := getLazyProc("Monitor_GetTop").Call(obj) 76 | return int32(ret) 77 | } 78 | 79 | func Monitor_GetWidth(obj uintptr) int32 { 80 | ret, _, _ := getLazyProc("Monitor_GetWidth").Call(obj) 81 | return int32(ret) 82 | } 83 | 84 | func Monitor_GetBoundsRect(obj uintptr) TRect { 85 | var ret TRect 86 | _, _, _ = getLazyProc("Monitor_GetBoundsRect").Call(obj, uintptr(unsafe.Pointer(&ret))) 87 | return ret 88 | } 89 | 90 | func Monitor_GetWorkareaRect(obj uintptr) TRect { 91 | var ret TRect 92 | _, _, _ = getLazyProc("Monitor_GetWorkareaRect").Call(obj, uintptr(unsafe.Pointer(&ret))) 93 | return ret 94 | } 95 | 96 | func Monitor_GetPrimary(obj uintptr) bool { 97 | ret, _, _ := getLazyProc("Monitor_GetPrimary").Call(obj) 98 | return DBoolToGoBool(ret) 99 | } 100 | 101 | func Monitor_GetPixelsPerInch(obj uintptr) int32 { 102 | ret, _, _ := getLazyProc("Monitor_GetPixelsPerInch").Call(obj) 103 | return int32(ret) 104 | } 105 | 106 | func Monitor_StaticClassType() TClass { 107 | r, _, _ := getLazyProc("Monitor_StaticClassType").Call() 108 | return TClass(r) 109 | } 110 | --------------------------------------------------------------------------------