-
Notifications
You must be signed in to change notification settings - Fork 0
/
tabpage.go
100 lines (74 loc) · 1.77 KB
/
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
// Copyright 2011 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 walk
import "syscall"
import . "github.com/lxn/go-winapi"
const tabPageWindowClass = `\o/ Walk_TabPage_Class \o/`
var tabPageBackgroundBrush Brush
func init() {
MustRegisterWindowClass(tabPageWindowClass)
tabPageBackgroundBrush, _ = NewSystemColorBrush(COLOR_WINDOW)
}
type TabPage struct {
ContainerBase
title string
tabWidget *TabWidget
titleChangedPublisher EventPublisher
}
func NewTabPage() (*TabPage, error) {
tp := &TabPage{}
if err := InitWidget(
tp,
nil,
tabPageWindowClass,
WS_POPUP,
WS_EX_CONTROLPARENT); err != nil {
return nil, err
}
tp.children = newWidgetList(tp)
tp.SetBackground(tabPageBackgroundBrush)
tp.MustRegisterProperty("Title", NewProperty(
func() interface{} {
return tp.Title()
},
func(v interface{}) error {
return tp.SetTitle(v.(string))
},
tp.titleChangedPublisher.Event()))
return tp, nil
}
func (tp *TabPage) Enabled() bool {
if tp.tabWidget != nil {
return tp.tabWidget.Enabled() && tp.enabled
}
return tp.enabled
}
func (tp *TabPage) Font() *Font {
if tp.font != nil {
return tp.font
} else if tp.tabWidget != nil {
return tp.tabWidget.Font()
}
return defaultFont
}
func (tp *TabPage) Title() string {
return tp.title
}
func (tp *TabPage) SetTitle(value string) error {
tp.title = value
tp.titleChangedPublisher.Publish()
if tp.tabWidget == nil {
return nil
}
return tp.tabWidget.onPageChanged(tp)
}
func (tp *TabPage) tcItem() *TCITEM {
text := syscall.StringToUTF16(tp.Title())
item := &TCITEM{
Mask: TCIF_TEXT,
PszText: &text[0],
CchTextMax: int32(len(text)),
}
return item
}