Skip to content

Commit

Permalink
导入第一个版本
Browse files Browse the repository at this point in the history
  • Loading branch information
joy999 committed Dec 9, 2013
1 parent 45ca65c commit c3eac23
Show file tree
Hide file tree
Showing 8 changed files with 632 additions and 0 deletions.
21 changes: 21 additions & 0 deletions Button.go
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
}
21 changes: 21 additions & 0 deletions CheckBox.go
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
}
75 changes: 75 additions & 0 deletions DropDownBox.go
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()
}
27 changes: 27 additions & 0 deletions GroupBox.go
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
}
49 changes: 49 additions & 0 deletions Label.go
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
}
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,8 @@ walkwrap
========

对于walk项目的二次封装。目的在于易用

install
========

go get github.com/joy999/walkwrap
Loading

0 comments on commit c3eac23

Please sign in to comment.