-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathspacer.go
59 lines (46 loc) · 1.28 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
// 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
const spacerWindowClass = `\o/ Walk_Spacer_Class \o/`
func init() {
MustRegisterWindowClass(spacerWindowClass)
}
type Spacer struct {
WidgetBase
sizeHint Size
layoutFlags LayoutFlags
}
func newSpacer(parent Container, layoutFlags LayoutFlags, sizeHint Size) (*Spacer, error) {
s := &Spacer{
layoutFlags: layoutFlags,
sizeHint: sizeHint,
}
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{})
}
func NewHSpacerFixed(parent Container, width int) (*Spacer, error) {
return newSpacer(parent, 0, Size{width, 0})
}
func NewVSpacer(parent Container) (*Spacer, error) {
return newSpacer(parent, ShrinkableHorz|ShrinkableVert|GrowableVert|GreedyVert, Size{})
}
func NewVSpacerFixed(parent Container, height int) (*Spacer, error) {
return newSpacer(parent, 0, Size{0, height})
}
func (s *Spacer) LayoutFlags() LayoutFlags {
return s.layoutFlags
}
func (s *Spacer) SizeHint() Size {
return s.sizeHint
}