summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--prefsize_windows.go7
-rw-r--r--sysdata_windows.go4
-rw-r--r--todo.md5
3 files changed, 14 insertions, 2 deletions
diff --git a/prefsize_windows.go b/prefsize_windows.go
index 5a34032..9a16f8d 100644
--- a/prefsize_windows.go
+++ b/prefsize_windows.go
@@ -62,6 +62,7 @@ var stdDlgSizes = [nctypes]dlgunits{
}
var (
+ _selectObject = gdi32.NewProc("SelectObject")
_getTextMetrics = gdi32.NewProc("GetTextMetricsW")
_getWindowDC = user32.NewProc("GetWindowDC")
_releaseDC = user32.NewProc("ReleaseDC")
@@ -79,6 +80,12 @@ func (s *sysData) preferredSize() (width int, height int) {
panic(fmt.Errorf("error getting DC for preferred size calculations: %v", err))
}
dc = _HANDLE(r1)
+ r1, _, err = _selectObject.Call(
+ uintptr(dc),
+ uintptr(unsafe.Pointer(*classTypes[s.ctype].font)))
+ if r1 == 0 { // failure
+ panic(fmt.Errorf("error loading control font into device context for preferred size calculation: %v", err))
+ }
r1, _, err = _getTextMetrics.Call(
uintptr(dc),
uintptr(unsafe.Pointer(&tm)))
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
}
diff --git a/todo.md b/todo.md
index cdf835f..8d11830 100644
--- a/todo.md
+++ b/todo.md
@@ -36,8 +36,9 @@ important things:
- NSComboBox scans the entered text to see if it matches one of the items and returns the index of that item if it does; find out how to suppress this so that it returns -1 unless the item was chosen from the list (like the other platforms)
- some Cocoa controls don't seem to resize correctly: Buttons have space around the edges and don't satisfy stretchiness
- make sure GTK+ documentation version point differences (x in 4.3.x) don't matter
-- button sizes and LineEdit sizes on Windows seem too big; Comboboxes have margins
- - Cocoa has similar margining issues (like on Comboboxes)
+- LineEdit heights on Windows seem too big; either that or LineEdit and Button text is not vertically centered properly
+ - are Checkboxes too small?
+ - Cocoa has similar margining issues (like Comboboxes having margins)
- sometimes the size of the drop-down part of a Combobox becomes 0 or 1 or some other impossibly small value on Windows
- make gcc (Unix)/clang (Mac OS X) pedantic about warnings/errors; also -Werror
- make sure scrollbars in Listbox work identically on all platforms (specifically the existence and autohiding of both horizontal and vertical scrollbars)