From 8cb3991ef9245ebc84d3760bd2bb279b0a3e09ed Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Tue, 1 Apr 2014 21:17:27 -0400 Subject: Fixed Windows control sizing: turns out simply calling GetTextMetrics() was not enough, as the GetDC() functions don't load the control font into the DC; we have to do it ourselves with SelectObject() (according to GetTextMetrics()'s docs on MSDN). Upon re-evaluation, the only things that need custom fonts are menus and statusbars; I don't know if menus can be done with the standard contorls and statusbars change the font of all controls inside... so how fonts are handled in classData needs to change now. --- sysdata_windows.go | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'sysdata_windows.go') diff --git a/sysdata_windows.go b/sysdata_windows.go index 978cbb3..6093f12 100644 --- a/sysdata_windows.go +++ b/sysdata_windows.go @@ -107,11 +107,13 @@ var classTypes = [nctypes]*classData{ name: _PROGRESS_CLASS, style: _PBS_SMOOTH | controlstyle, xstyle: 0 | controlxstyle, + font: &controlFont, }, c_area: &classData{ register: registerAreaWndClass, style: areastyle, xstyle: areaxstyle, + font: &controlFont, }, } @@ -192,6 +194,8 @@ func (s *sysData) make(window *sysData) (err error) { ret: ret, } <-ret + } else if s.ctype != c_window { + panic(fmt.Errorf("internal ui package error: control type %d does not have a font (needed for preferred size calculations)", s.ctype)) } return nil } -- cgit v1.2.3