-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsplitterhandle.go
68 lines (52 loc) · 1.38 KB
/
splitterhandle.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 . "github.com/lxn/go-winapi"
const splitterHandleWindowClass = `\o/ Walk_SplitterHandle_Class \o/`
func init() {
MustRegisterWindowClass(splitterHandleWindowClass)
}
type splitterHandle struct {
WidgetBase
}
func newSplitterHandle(splitter *Splitter) (*splitterHandle, error) {
if splitter == nil {
return nil, newError("splitter cannot be nil")
}
sh := &splitterHandle{}
sh.parent = splitter
if err := InitWidget(
sh,
splitter,
splitterHandleWindowClass,
WS_CHILD|WS_VISIBLE,
0); err != nil {
return nil, err
}
if err := sh.setAndClearStyleBits(0, WS_CLIPSIBLINGS); err != nil {
return nil, err
}
return sh, nil
}
func (sh *splitterHandle) LayoutFlags() LayoutFlags {
splitter := sh.Parent().(*Splitter)
if splitter.Orientation() == Horizontal {
return ShrinkableVert | GrowableVert | GreedyVert
}
return ShrinkableHorz | GrowableHorz | GreedyHorz
}
func (sh *splitterHandle) MinSizeHint() Size {
return sh.SizeHint()
}
func (sh *splitterHandle) SizeHint() Size {
splitter := sh.Parent().(*Splitter)
handleWidth := splitter.HandleWidth()
var size Size
if splitter.Orientation() == Horizontal {
size.Width = handleWidth
} else {
size.Height = handleWidth
}
return size
}