-
Notifications
You must be signed in to change notification settings - Fork 0
/
tabpage.go
68 lines (49 loc) · 1.3 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
// 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 tabPageWindowClassRegistered bool
type TabPage struct {
ContainerBase
title string
tabWidget *TabWidget
}
func NewTabPage() (*TabPage, error) {
ensureRegisteredWindowClass(tabPageWindowClass, &tabPageWindowClassRegistered)
tp := &TabPage{}
if err := initWidget(
tp,
nil,
tabPageWindowClass,
WS_POPUP,
WS_EX_CONTROLPARENT /*|WS_EX_TRANSPARENT*/); err != nil {
return nil, err
}
tp.children = newWidgetList(tp)
// FIXME: The next line, together with WS_EX_TRANSPARENT, would make the tab
// page background transparent, but it doesn't work on XP :(
// tp.SetBackground(NullBrush())
return tp, nil
}
func (tp *TabPage) Title() string {
return tp.title
}
func (tp *TabPage) SetTitle(value string) error {
tp.title = value
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
}