-
Notifications
You must be signed in to change notification settings - Fork 2
/
tabpage.go
103 lines (77 loc) · 1.81 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
101
102
103
// 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 (
"github.com/lxn/win"
)
const tabPageWindowClass = `\o/ Walk_TabPage_Class \o/`
var tabPageBackgroundBrush Brush
func init() {
MustRegisterWindowClass(tabPageWindowClass)
tabPageBackgroundBrush, _ = NewSystemColorBrush(win.COLOR_WINDOW)
}
type TabPage struct {
ContainerBase
image *Bitmap
title string
tabWidget *TabWidget
titleChangedPublisher EventPublisher
}
func NewTabPage() (*TabPage, error) {
tp := new(TabPage)
if err := InitWindow(
tp,
nil,
tabPageWindowClass,
win.WS_POPUP,
win.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) Image() *Bitmap {
return tp.image
}
func (tp *TabPage) SetImage(value *Bitmap) error {
tp.image = value
if tp.tabWidget == nil {
return nil
}
return tp.tabWidget.onPageChanged(tp)
}
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)
}