-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtabpage.go
54 lines (44 loc) · 974 Bytes
/
tabpage.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
package main
import (
"github.com/chenqinghe/walk"
. "github.com/chenqinghe/walk/declarative"
"github.com/gomodule/redigo/redis"
"github.com/sirupsen/logrus"
)
type TabPageEx struct {
*walk.TabPage
content *TextEditEx
conn redis.Conn
}
func (tw *TabWidgetEx) NewTabPageEx() (*TabPageEx, error) {
tabpageEx := &TabPageEx{
content: nil,
conn: nil,
}
if err := (TabPage{
AssignTo: &tabpageEx.TabPage,
Image: "img/redis.ico",
Layout: HBox{
MarginsZero: true,
SpacingZero: true,
},
OnClosed: func() {
if tw.Pages().Len() == 0 {
tw.root.MainWindow.Close()
}
},
}).Create(NewBuilder(tw.root)); err != nil {
logrus.Errorln("create tabpage error:", err)
return nil, err
}
textedit, err := NewTextEdit(tw.root, tabpageEx)
if err != nil {
return nil, err
}
tabpageEx.SetContent(textedit)
tw.AddPage(tabpageEx)
return tabpageEx, nil
}
func (p *TabPageEx) SetContent(textedit *TextEditEx) {
p.content = textedit
}