Skip to content

Commit

Permalink
Update to the correct class inheritance relationship
Browse files Browse the repository at this point in the history
Update to the correct class inheritance relationship
  • Loading branch information
twgh committed Nov 4, 2021
1 parent f7bedd6 commit b246a53
Show file tree
Hide file tree
Showing 18 changed files with 100 additions and 154 deletions.
8 changes: 2 additions & 6 deletions adapter/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,13 @@
package adapter

import (
"github.com/twgh/xcgui/objectbase"
"github.com/twgh/xcgui/xc"
)

// 数据适配器.
type adapter struct {
Handle int // hAdapter.
}

// 给本类的Handle赋值.
func (a *adapter) SetHandle(hAdapter int) {
a.Handle = hAdapter
objectbase.ObjectBase
}

// 数据适配器_增加引用计数.
Expand Down
13 changes: 4 additions & 9 deletions bkmanager/bkmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@
package bkmanager

import (
"github.com/twgh/xcgui/objectbase"
"github.com/twgh/xcgui/res"
"github.com/twgh/xcgui/xc"
)

// 背景管理器.
type BkManager struct {
Handle int // HBKM.
objectbase.ObjectBase
}

// 背景_创建, 创建背景管理器.
func NewBkManager() *BkManager {
p := &BkManager{
Handle: xc.XBkM_Create(),
}
p := &BkManager{}
p.SetHandle(xc.XBkM_Create())
return p
}

Expand All @@ -37,11 +37,6 @@ func NewBkManagerByName(name string) *BkManager {
return nil
}

// 给本类的HBKM赋值.
func (b *BkManager) SetHandle(hBkm int) {
b.Handle = hBkm
}

// 背景_销毁.
func (b *BkManager) Destroy() int {
return xc.XBkM_Destroy(b.Handle)
Expand Down
22 changes: 9 additions & 13 deletions drawx/draw.go
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
// 图形绘制.
package drawx

import "github.com/twgh/xcgui/xc"
import (
"github.com/twgh/xcgui/objectbase"
"github.com/twgh/xcgui/xc"
)

// 图形绘制.
type Draw struct {
Handle int // HDRAW.
objectbase.ObjectBase
}

// 绘制_创建, 创建图形绘制模块实例, 返回句柄.
//
// hWindow: 窗口句柄.
func NewDraw(hWindow int) *Draw {
p := &Draw{
Handle: xc.XDraw_Create(hWindow),
}
p := &Draw{}
p.SetHandle(xc.XDraw_Create(hWindow))
return p
}

Expand All @@ -24,9 +26,8 @@ func NewDraw(hWindow int) *Draw {
//
// hdc: hdc句柄.
func NewDrawGDI(hWindow, hdc int) *Draw {
p := &Draw{
Handle: xc.XDraw_CreateGDI(hWindow, hdc),
}
p := &Draw{}
p.SetHandle(xc.XDraw_CreateGDI(hWindow, hdc))
return p
}

Expand All @@ -37,11 +38,6 @@ func NewDrawByHandle(handle int) *Draw {
return p
}

// 给本类的Handle赋值.
func (a *Draw) SetHandle(hDraw int) {
a.Handle = hDraw
}

// 绘制_销毁, 销毁图形绘制模块实例句柄.
func (d *Draw) Destroy() int {
return xc.XDraw_Destroy(d.Handle)
Expand Down
48 changes: 18 additions & 30 deletions font/font.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@
package font

import (
"github.com/twgh/xcgui/objectbase"
"github.com/twgh/xcgui/res"
"github.com/twgh/xcgui/xc"
)

// 字体.
type Font struct {
Handle int // HFONTX.
objectbase.ObjectBase
}

// 字体_创建, 创建炫彩字体, 当字体句柄与元素关联后, 会自动释放.
//
// size: 字体大小.
func NewFont(size int) *Font {
p := &Font{
Handle: xc.XFont_Create(size),
}
p := &Font{}
p.SetHandle(xc.XFont_Create(size))
return p
}

Expand All @@ -29,39 +29,35 @@ func NewFont(size int) *Font {
//
// style: 字体样式, FontStyle_.
func NewFontEX(pName string, size int, style int) *Font {
p := &Font{
Handle: xc.XFont_CreateEx(pName, size, style),
}
p := &Font{}
p.SetHandle(xc.XFont_CreateEx(pName, size, style))
return p
}

// 字体_创建从LOGFONT, 创建炫彩字体.
//
// pFontInfo: 字体信息.
func NewFontLOGFONTW(pFontInfo *xc.LOGFONTW) *Font {
p := &Font{
Handle: xc.XFont_CreateLOGFONTW(pFontInfo),
}
p := &Font{}
p.SetHandle(xc.XFont_CreateLOGFONTW(pFontInfo))
return p
}

// 字体_创建从HFONT, 创建炫彩字体从现有HFONT字体.
//
// hFont: 字体句柄.
func NewFontFromHFONT(hFont int) *Font {
p := &Font{
Handle: xc.XFont_CreateFromHFONT(hFont),
}
p := &Font{}
p.SetHandle(xc.XFont_CreateFromHFONT(hFont))
return p
}

// 字体_创建从Font, 创建炫彩字体从GDI+字体(Font).
//
// pFont: GDI+字体指针(Font*).
func NewFontFromFont(pFont int) *Font {
p := &Font{
Handle: xc.XFont_CreateFromFont(pFont),
}
p := &Font{}
p.SetHandle(xc.XFont_CreateFromFont(pFont))
return p
}

Expand All @@ -73,9 +69,8 @@ func NewFontFromFont(pFont int) *Font {
//
// style: 字体样式, FontStyle_.
func NewFontFromFile(pFontFile string, size int, style int) *Font {
p := &Font{
Handle: xc.XFont_CreateFromFile(pFontFile, size, style),
}
p := &Font{}
p.SetHandle(xc.XFont_CreateFromFile(pFontFile, size, style))
return p
}

Expand All @@ -89,9 +84,8 @@ func NewFontFromFile(pFontFile string, size int, style int) *Font {
//
// style: 字体样式, FontStyle_.
func NewFontFromMem(data, length, fontSize, style int) *Font {
p := &Font{
Handle: xc.XFont_CreateFromMem(data, length, fontSize, style),
}
p := &Font{}
p.SetHandle(xc.XFont_CreateFromMem(data, length, fontSize, style))
return p
}

Expand All @@ -107,9 +101,8 @@ func NewFontFromMem(data, length, fontSize, style int) *Font {
//
// hModule: xx.
func NewFontFromRes(id int, pType string, fontSize int, style int, hModule int) *Font {
p := &Font{
Handle: xc.XFont_CreateFromRes(id, pType, fontSize, style, hModule),
}
p := &Font{}
p.SetHandle(xc.XFont_CreateFromRes(id, pType, fontSize, style, hModule))
return p
}

Expand All @@ -131,11 +124,6 @@ func NewFontByName(name string) *Font {
return nil
}

// 给本类的Handle赋值.
func (f *Font) SetHandle(hFontX int) {
f.Handle = hFontX
}

// 字体_启用自动销毁, 是否自动销毁.
//
// bEnable: 是否启用.
Expand Down
Loading

0 comments on commit b246a53

Please sign in to comment.