/
pushbutton.go
54 lines (45 loc) · 1.36 KB
/
pushbutton.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// Copyright 2012 The Walk Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package declarative
import (
"github.com/lxn/walk"
)
type PushButton struct {
AssignTo **walk.PushButton
Name string
Disabled bool
Hidden bool
Font Font
MinSize Size
MaxSize Size
StretchFactor int
Row int
RowSpan int
Column int
ColumnSpan int
ContextMenuActions []*walk.Action
Text string
OnClicked walk.EventHandler
}
func (pb PushButton) Create(parent walk.Container) error {
w, err := walk.NewPushButton(parent)
if err != nil {
return err
}
return InitWidget(pb, w, func() error {
if err := w.SetText(pb.Text); err != nil {
return err
}
if pb.OnClicked != nil {
w.Clicked().Attach(pb.OnClicked)
}
if pb.AssignTo != nil {
*pb.AssignTo = w
}
return nil
})
}
func (pb PushButton) WidgetInfo() (name string, disabled, hidden bool, font *Font, minSize, maxSize Size, stretchFactor, row, rowSpan, column, columnSpan int, contextMenuActions []*walk.Action) {
return pb.Name, pb.Disabled, pb.Hidden, &pb.Font, pb.MinSize, pb.MaxSize, pb.StretchFactor, pb.Row, pb.RowSpan, pb.Column, pb.ColumnSpan, pb.ContextMenuActions
}