summaryrefslogtreecommitdiff
path: root/prefsize_windows.go
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2014-03-09 19:34:43 -0400
committerPietro Gagliardi <[email protected]>2014-03-09 19:34:43 -0400
commitab11900d43b02ab2c01f5963b3cfaf8b623ebd58 (patch)
tree19634c472da042e9091d7b77bc47d49785196fb9 /prefsize_windows.go
parent5a7cfedb84ec964b381406e4fc13e14bc994ba08 (diff)
Changed Windows sysData.preferredSize() to panic on error, since the other platforms don't return explicit errors either.
Diffstat (limited to 'prefsize_windows.go')
-rw-r--r--prefsize_windows.go7
1 files changed, 4 insertions, 3 deletions
diff --git a/prefsize_windows.go b/prefsize_windows.go
index 3dac306..c6f1ca2 100644
--- a/prefsize_windows.go
+++ b/prefsize_windows.go
@@ -2,6 +2,7 @@
package ui
import (
+ "fmt"
// "syscall"
"unsafe"
)
@@ -74,14 +75,14 @@ func (s *sysData) preferredSize() (width int, height int) {
// TODO use GetDC() and not GetWindowDC()?
r1, _, err := _getWindowDC.Call(uintptr(s.hwnd))
if r1 == 0 { // failure
- panic(err) // TODO return it instead
+ panic(fmt.Errorf("error getting DC for preferred size calculations: %v", err))
}
dc = _HANDLE(r1)
r1, _, err = _getTextMetrics.Call(
uintptr(dc),
uintptr(unsafe.Pointer(&tm)))
if r1 == 0 { // failure
- panic(err) // TODO return it instead
+ panic(fmt.Errorf("error getting text metrics for preferred size calculations: %v", err))
}
baseX = int(tm.tmAveCharWidth) // TODO not optimal; third reference has better way
baseY = int(tm.tmHeight)
@@ -89,7 +90,7 @@ func (s *sysData) preferredSize() (width int, height int) {
uintptr(s.hwnd),
uintptr(dc))
if r1 == 0 { // failure
- panic(err) // TODO return it instead
+ panic(fmt.Errorf("error releasing DC for preferred size calculations: %v", err))
}
// now that we have the conversion factors...