summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorAlexander Neumann <alexander.neumann@picos-software.com>2019-05-06 12:01:05 +0200
committerAlexander Neumann <alexander.neumann@picos-software.com>2019-05-06 12:01:05 +0200
commit7014d71499906ddf43e9f7a4e9222609c88157bf (patch)
tree7a540e74a42c628f7f476af3b751fc9613ac5016
parentMerge branch 'master' of github.com:lxn/walk (diff)
downloadwireguard-windows-7014d71499906ddf43e9f7a4e9222609c88157bf.tar.xz
wireguard-windows-7014d71499906ddf43e9f7a4e9222609c88157bf.zip
Export some HIDPI related helpers
-rw-r--r--container.go8
-rw-r--r--form.go6
-rw-r--r--toolbar.go2
-rw-r--r--util.go4
-rw-r--r--window.go26
5 files changed, 23 insertions, 23 deletions
diff --git a/container.go b/container.go
index be0814f5..64d7b791 100644
--- a/container.go
+++ b/container.go
@@ -187,13 +187,13 @@ func (l *LayoutBase) SetSpacing(value int) error {
func (l *LayoutBase) updateMargins() {
if l.container != nil {
- l.margins = l.container.AsWindowBase().marginsFrom96DPI(l.margins96dpi)
+ l.margins = l.container.AsWindowBase().MarginsFrom96DPI(l.margins96dpi)
}
}
func (l *LayoutBase) updateSpacing() {
if l.container != nil {
- l.spacing = l.container.AsWindowBase().intFrom96DPI(l.spacing96dpi)
+ l.spacing = l.container.AsWindowBase().IntFrom96DPI(l.spacing96dpi)
}
}
@@ -431,8 +431,8 @@ func (cb *ContainerBase) applyFont(font *Font) {
applyFontToDescendants(cb.window.(Widget), font)
}
-func (cb *ContainerBase) applyDPI(dpi int) {
- cb.WidgetBase.applyDPI(dpi)
+func (cb *ContainerBase) ApplyDPI(dpi int) {
+ cb.WidgetBase.ApplyDPI(dpi)
applyDPIToDescendants(cb.window.(Widget), dpi)
diff --git a/form.go b/form.go
index 74878352..2a7117af 100644
--- a/form.go
+++ b/form.go
@@ -683,8 +683,8 @@ func (fb *FormBase) WndProc(hwnd win.HWND, msg uint32, wParam, lParam uintptr) u
}
mmi.PtMinTrackSize = win.POINT{
- int32(fb.intFrom96DPI(maxi(min.Width, fb.minSize.Width))),
- int32(fb.intFrom96DPI(maxi(min.Height, fb.minSize.Height))),
+ int32(fb.IntFrom96DPI(maxi(min.Width, fb.minSize.Width))),
+ int32(fb.IntFrom96DPI(maxi(min.Height, fb.minSize.Height))),
}
return 0
@@ -712,7 +712,7 @@ func (fb *FormBase) WndProc(hwnd win.HWND, msg uint32, wParam, lParam uintptr) u
rc := (*win.RECT)(unsafe.Pointer(lParam))
fb.window.SetBounds(rectangleFromRECT(*rc))
- fb.applyDPI(int(win.HIWORD(uint32(wParam))))
+ fb.ApplyDPI(int(win.HIWORD(uint32(wParam))))
case win.WM_SYSCOMMAND:
if wParam == win.SC_CLOSE {
diff --git a/toolbar.go b/toolbar.go
index 82570646..76e60900 100644
--- a/toolbar.go
+++ b/toolbar.go
@@ -152,7 +152,7 @@ func (tb *ToolBar) applyDefaultButtonWidth() error {
return nil
}
- width := tb.intFrom96DPI(tb.defaultButtonWidth)
+ width := tb.IntFrom96DPI(tb.defaultButtonWidth)
lParam := uintptr(win.MAKELONG(uint16(width), uint16(width)))
if 0 == tb.SendMessage(win.TB_SETBUTTONWIDTH, 0, lParam) {
diff --git a/util.go b/util.go
index 6036b581..566d8dad 100644
--- a/util.go
+++ b/util.go
@@ -258,14 +258,14 @@ func applyFontToDescendants(window Window, font *Font) {
func applyDPIToDescendants(window Window, dpi int) {
wb := window.AsWindowBase()
- wb.applyDPI(dpi)
+ wb.ApplyDPI(dpi)
walkDescendants(window, func(w Window) bool {
if w.Handle() == wb.hWnd {
return true
}
- w.(applyDPIer).applyDPI(dpi)
+ w.(ApplyDPIer).ApplyDPI(dpi)
return true
})
diff --git a/window.go b/window.go
index 33e32204..d7da77d8 100644
--- a/window.go
+++ b/window.go
@@ -808,21 +808,21 @@ func (wb *WindowBase) DPI() int {
return wb.dpi
}
-type applyDPIer interface {
- applyDPI(dpi int)
+type ApplyDPIer interface {
+ ApplyDPI(dpi int)
}
-func (wb *WindowBase) applyDPI(dpi int) {
+func (wb *WindowBase) ApplyDPI(dpi int) {
wb.dpi = dpi
wb.window.SetFont(wb.window.Font())
}
-func (wb *WindowBase) intFrom96DPI(value int) int {
+func (wb *WindowBase) IntFrom96DPI(value int) int {
return wb.scaleInt(value, float64(wb.DPI())/96.0)
}
-func (wb *WindowBase) intTo96DPI(value int) int {
+func (wb *WindowBase) IntTo96DPI(value int) int {
return wb.scaleInt(value, 96.0/float64(wb.DPI()))
}
@@ -830,11 +830,11 @@ func (wb *WindowBase) scaleInt(value int, scale float64) int {
return int(float64(value) * scale)
}
-func (wb *WindowBase) marginsFrom96DPI(value Margins) Margins {
+func (wb *WindowBase) MarginsFrom96DPI(value Margins) Margins {
return wb.scaleMargins(value, float64(wb.DPI())/96.0)
}
-func (wb *WindowBase) marginsTo96DPI(value Margins) Margins {
+func (wb *WindowBase) MarginsTo96DPI(value Margins) Margins {
return wb.scaleMargins(value, 96.0/float64(wb.DPI()))
}
@@ -847,11 +847,11 @@ func (wb *WindowBase) scaleMargins(value Margins, scale float64) Margins {
}
}
-func (wb *WindowBase) pointFrom96DPI(value Point) Point {
+func (wb *WindowBase) PointFrom96DPI(value Point) Point {
return wb.scalePoint(value, float64(wb.DPI())/96.0)
}
-func (wb *WindowBase) pointTo96DPI(value Point) Point {
+func (wb *WindowBase) PointTo96DPI(value Point) Point {
return wb.scalePoint(value, 96.0/float64(wb.DPI()))
}
@@ -862,11 +862,11 @@ func (wb *WindowBase) scalePoint(value Point, scale float64) Point {
}
}
-func (wb *WindowBase) rectangleFrom96DPI(value Rectangle) Rectangle {
+func (wb *WindowBase) RectangleFrom96DPI(value Rectangle) Rectangle {
return wb.scaleRectangle(value, float64(wb.DPI())/96.0)
}
-func (wb *WindowBase) rectangleTo96DPI(value Rectangle) Rectangle {
+func (wb *WindowBase) RectangleTo96DPI(value Rectangle) Rectangle {
return wb.scaleRectangle(value, 96.0/float64(wb.DPI()))
}
@@ -879,11 +879,11 @@ func (wb *WindowBase) scaleRectangle(value Rectangle, scale float64) Rectangle {
}
}
-func (wb *WindowBase) sizeFrom96DPI(value Size) Size {
+func (wb *WindowBase) SizeFrom96DPI(value Size) Size {
return wb.scaleSize(value, float64(wb.DPI())/96.0)
}
-func (wb *WindowBase) sizeTo96DPI(value Size) Size {
+func (wb *WindowBase) SizeTo96DPI(value Size) Size {
return wb.scaleSize(value, 96.0/float64(wb.DPI()))
}