-
Notifications
You must be signed in to change notification settings - Fork 0
/
spacer.go
77 lines (60 loc) · 1.75 KB
/
spacer.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
// 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.
// +build windows
package walk
const spacerWindowClass = `\o/ Walk_Spacer_Class \o/`
func init() {
MustRegisterWindowClass(spacerWindowClass)
}
type Spacer struct {
WidgetBase
sizeHint Size
layoutFlags LayoutFlags
greedyLocallyOnly bool
}
type SpacerCfg struct {
LayoutFlags LayoutFlags
SizeHint Size
GreedyLocallyOnly bool
}
func NewSpacerWithCfg(parent Container, cfg *SpacerCfg) (*Spacer, error) {
return newSpacer(parent, cfg.LayoutFlags, cfg.SizeHint, cfg.GreedyLocallyOnly)
}
func newSpacer(parent Container, layoutFlags LayoutFlags, sizeHint Size, greedyLocallyOnly bool) (*Spacer, error) {
s := &Spacer{
layoutFlags: layoutFlags,
sizeHint: sizeHint,
greedyLocallyOnly: greedyLocallyOnly,
}
if err := InitWidget(
s,
parent,
spacerWindowClass,
0,
0); err != nil {
return nil, err
}
return s, nil
}
func NewHSpacer(parent Container) (*Spacer, error) {
return newSpacer(parent, ShrinkableHorz|ShrinkableVert|GrowableHorz|GreedyHorz, Size{}, false)
}
func NewHSpacerFixed(parent Container, width int) (*Spacer, error) {
return newSpacer(parent, 0, Size{width, 0}, false)
}
func NewVSpacer(parent Container) (*Spacer, error) {
return newSpacer(parent, ShrinkableHorz|ShrinkableVert|GrowableVert|GreedyVert, Size{}, false)
}
func NewVSpacerFixed(parent Container, height int) (*Spacer, error) {
return newSpacer(parent, 0, Size{0, height}, false)
}
func (s *Spacer) LayoutFlags() LayoutFlags {
return s.layoutFlags
}
func (s *Spacer) MinSizeHint() Size {
return s.sizeHint
}
func (s *Spacer) SizeHint() Size {
return s.sizeHint
}