-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
632 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package main | ||
|
||
import ( | ||
"github.com/lxn/walk" | ||
) | ||
|
||
type Button struct { | ||
*walk.PushButton | ||
} | ||
|
||
func NewButton(parent walk.Container, text string, width, height, x, y int) *Button { | ||
b := new(Button) | ||
b.PushButton, _ = walk.NewPushButton(parent) | ||
b.SetWidth(width) | ||
b.SetHeight(height) | ||
b.SetY(y) | ||
b.SetX(x) | ||
b.SetText(text) | ||
|
||
return b | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package main | ||
|
||
import ( | ||
"github.com/lxn/walk" | ||
) | ||
|
||
type CheckBox struct { | ||
*walk.CheckBox | ||
} | ||
|
||
func NewCheckBox(parent walk.Container, text string, width, height, x, y int) *CheckBox { | ||
b := new(CheckBox) | ||
b.CheckBox, _ = walk.NewCheckBox(parent) | ||
b.SetWidth(width) | ||
b.SetHeight(height) | ||
b.SetY(y) | ||
b.SetX(x) | ||
b.SetText(text) | ||
|
||
return b | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package main | ||
|
||
import ( | ||
"github.com/lxn/walk" | ||
) | ||
|
||
type DropDownBox struct { | ||
*walk.ComboBox | ||
model *DropDownBoxModel | ||
} | ||
|
||
func NewDropDownBox(parent walk.Container, text string, width, height, x, y int) *DropDownBox { | ||
b := new(DropDownBox) | ||
|
||
b.ComboBox, _ = walk.NewDropDownBox(parent) | ||
b.SetWidth(width) | ||
b.SetHeight(height) | ||
b.SetY(y) | ||
b.SetX(x) | ||
|
||
b.model = NewDropDownBoxModel() | ||
b.SetModel(b.model) | ||
|
||
return b | ||
} | ||
|
||
func (this *DropDownBox) AddItem(name string) { | ||
this.model.Add(name) | ||
} | ||
|
||
type DropDownBoxModel struct { | ||
walk.ListModelBase | ||
data []string | ||
} | ||
|
||
/* | ||
// ListModel is the interface that a model must implement to support widgets | ||
// like ComboBox. | ||
type ListModel interface { | ||
// ItemCount returns the number of items in the model. | ||
ItemCount() int | ||
// Value returns the value that should be displayed for the given index. | ||
Value(index int) interface{} | ||
// ItemsReset returns the event that the model should publish when the | ||
// number of its items changes. | ||
ItemsReset() *Event | ||
// ItemChanged returns the event that the model should publish when an item | ||
// was changed. | ||
ItemChanged() *IntEvent | ||
} | ||
*/ | ||
|
||
func NewDropDownBoxModel() *DropDownBoxModel { | ||
d := new(DropDownBoxModel) | ||
d.data = make([]string, 0) | ||
|
||
return d | ||
} | ||
|
||
func (this *DropDownBoxModel) Value(index int) interface{} { | ||
return this.data[index] | ||
} | ||
|
||
func (this *DropDownBoxModel) ItemCount() int { | ||
return len(this.data) | ||
} | ||
|
||
func (this *DropDownBoxModel) Add(v string) { | ||
this.data = append(this.data, v) | ||
|
||
this.PublishItemsReset() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package main | ||
|
||
import ( | ||
"github.com/lxn/walk" | ||
) | ||
|
||
type GroupBox struct { | ||
*walk.GroupBox | ||
} | ||
|
||
func NewGroupBox(parent walk.Container, text string, width, height, x, y int) *GroupBox { | ||
var err error | ||
b := new(GroupBox) | ||
b.GroupBox, err = walk.NewGroupBox(parent) | ||
|
||
if err != nil { | ||
return nil | ||
} | ||
|
||
b.SetWidth(width) | ||
b.SetHeight(height) | ||
b.SetY(y) | ||
b.SetX(x) | ||
b.GroupBox.SetTitle(text) | ||
|
||
return b | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package main | ||
|
||
import ( | ||
"github.com/lxn/walk" | ||
|
||
// "github.com/lxn/win" | ||
) | ||
|
||
type Label struct { | ||
*walk.Label | ||
} | ||
|
||
func NewLabel(parent walk.Container, txt string, w, h, x, y int) *Label { | ||
ll := new(Label) | ||
ll.Label, _ = walk.NewLabel(parent) | ||
|
||
font, _ := walk.NewFont("微软雅黑", 9, 0) | ||
ll.Label.SetFont(font) | ||
//WS_EX_TRANSPARENT | ||
ll.Label.SetText(txt) | ||
ll.Label.SetWidth(w) | ||
ll.Label.SetHeight(h) | ||
ll.Label.SetX(x) | ||
ll.Label.SetY(y) | ||
|
||
//win.SetWindowLongPtr(ll.Label.Handle(), win.GWL_EXSTYLE, win.WS_EX_TRANSPARENT) | ||
|
||
return ll | ||
} | ||
|
||
type LinkLabel struct { | ||
*walk.Label | ||
} | ||
|
||
func NewLinkLabel(parent walk.Container, txt string, w, h, x, y int) *LinkLabel { | ||
ll := new(LinkLabel) | ||
ll.Label, _ = walk.NewLabel(parent) | ||
|
||
font, _ := walk.NewFont("微软雅黑", 9, walk.FontUnderline) | ||
ll.Label.SetFont(font) | ||
|
||
ll.Label.SetText(txt) | ||
ll.Label.SetWidth(w) | ||
ll.Label.SetHeight(h) | ||
ll.Label.SetX(x) | ||
ll.Label.SetY(y) | ||
|
||
return ll | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,8 @@ walkwrap | |
======== | ||
|
||
对于walk项目的二次封装。目的在于易用 | ||
|
||
install | ||
======== | ||
|
||
go get github.com/joy999/walkwrap |
Oops, something went wrong.