summaryrefslogtreecommitdiffstatshomepage
path: root/separator.go
blob: 48f11cd273baddf9b8e3d99f71539d9491f40722 (plain) (blame)
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
// Copyright 2017 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

import (
	"github.com/lxn/win"
)

type Separator struct {
	WidgetBase
	vertical bool
}

func NewHSeparator(parent Container) (*Separator, error) {
	return newSeparator(parent, false)
}

func NewVSeparator(parent Container) (*Separator, error) {
	return newSeparator(parent, true)
}

func newSeparator(parent Container, vertical bool) (*Separator, error) {
	s := &Separator{vertical: vertical}

	if err := InitWidget(
		s,
		parent,
		"STATIC",
		win.WS_VISIBLE|win.SS_ETCHEDHORZ,
		0); err != nil {
		return nil, err
	}

	return s, nil
}

func (s *Separator) LayoutFlags() LayoutFlags {
	if s.vertical {
		return GrowableHorz | GreedyHorz
	} else {
		return GrowableVert | GreedyVert
	}
}

func (s *Separator) MinSizeHint() Size {
	return Size{2, 2}
}

func (s *Separator) SizeHint() Size {
	return s.MinSizeHint()
}