summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorAlexander Neumann <alexander.neumann@picos-software.com>2019-04-29 15:00:23 +0200
committerAlexander Neumann <alexander.neumann@picos-software.com>2019-04-29 15:00:23 +0200
commit263894095368477aa4cec096d999739c17b5128d (patch)
tree0ebcac7e91fdddcc662be2db6e849b98e92ad816
parentMerge pull request #494 from zx2c4-forks/jd/db (diff)
downloadwireguard-windows-263894095368477aa4cec096d999739c17b5128d.tar.xz
wireguard-windows-263894095368477aa4cec096d999739c17b5128d.zip
GroupBox: Fix overdrawing of contained composite with double buffering
-rw-r--r--groupbox.go18
1 files changed, 13 insertions, 5 deletions
diff --git a/groupbox.go b/groupbox.go
index 4135e0fe..576a85fa 100644
--- a/groupbox.go
+++ b/groupbox.go
@@ -25,6 +25,7 @@ type GroupBox struct {
hWndGroupBox win.HWND
checkBox *CheckBox
composite *Composite
+ headerHeight int
titleChangedPublisher EventPublisher
}
@@ -56,6 +57,7 @@ func NewGroupBox(parent Container) (*GroupBox, error) {
}
setWindowFont(gb.hWndGroupBox, gb.Font())
+ gb.updateHeaderHeight()
var err error
@@ -133,7 +135,7 @@ func (gb *GroupBox) MinSizeHint() Size {
cmsh.Height += s.Height
}
- return Size{cmsh.Width + 2, cmsh.Height + 14}
+ return Size{cmsh.Width + 2, cmsh.Height + gb.headerHeight}
}
func (gb *GroupBox) SizeHint() Size {
@@ -154,7 +156,7 @@ func (gb *GroupBox) HeightForWidth(width int) int {
cmsh.Height += s.Height
}
- return cmsh.Height + 14
+ return cmsh.Height + gb.headerHeight
}
func (gb *GroupBox) ClientBounds() Rectangle {
@@ -171,8 +173,11 @@ func (gb *GroupBox) ClientBounds() Rectangle {
cb.Height -= s.Height
}
- // FIXME: Use appropriate margins
- return Rectangle{cb.X + 1, cb.Y + 14, cb.Width - 2, cb.Height - 14}
+ return Rectangle{cb.X + 1, cb.Y + gb.headerHeight, cb.Width - 2, cb.Height - gb.headerHeight}
+}
+
+func (gb *GroupBox) updateHeaderHeight() {
+ gb.headerHeight = gb.calculateTextSizeImpl("gM").Height
}
func (gb *GroupBox) Persistent() bool {
@@ -231,6 +236,8 @@ func (gb *GroupBox) applyFont(font *Font) {
if gb.composite != nil {
gb.composite.applyFont(font)
}
+
+ gb.updateHeaderHeight()
}
func (gb *GroupBox) SetSuspended(suspend bool) {
@@ -361,10 +368,11 @@ func (gb *GroupBox) WndProc(hwnd win.HWND, msg uint32, wParam, lParam uintptr) u
if gb.Checkable() {
s := gb.checkBox.SizeHint()
- gb.checkBox.SetBounds(Rectangle{9, 14, s.Width, s.Height})
+ gb.checkBox.SetBounds(Rectangle{gb.headerHeight * 2 / 3, gb.headerHeight, s.Width, s.Height})
}
gbcb := gb.ClientBounds()
+ gbcb.Height -= 2
gb.composite.SetBounds(gbcb)
}
}