summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--controls_windows.go5
-rw-r--r--prefsize_windows.go26
-rw-r--r--todo.md3
3 files changed, 31 insertions, 3 deletions
diff --git a/controls_windows.go b/controls_windows.go
index e7a72c9..581c1a7 100644
--- a/controls_windows.go
+++ b/controls_windows.go
@@ -40,6 +40,7 @@ const (
_BS_NOTIFY = 0x00004000
_BS_FLAT = 0x00008000
_BS_RIGHTBUTTON = _BS_LEFTTEXT
+
// from commctrl.h
// _BS_SPLITBUTTON = 0x0000000C // Windows Vista and newer and(/or?) comctl6 only
// _BS_DEFSPLITBUTTON = 0x0000000D // Windows Vista and newer and(/or?) comctl6 only
@@ -59,6 +60,10 @@ const (
_BM_GETIMAGE = 0x00F6
_BM_SETIMAGE = 0x00F7
_BM_SETDONTCLICK = 0x00F8
+
+ // from commctrl.h
+ _BCM_FIRST = 0x1600
+ _BCM_GETIDEALSIZE = (_BCM_FIRST + 0x0001)
)
// Button WM_COMMAND notifications.
diff --git a/prefsize_windows.go b/prefsize_windows.go
index 4425f64..5e761ec 100644
--- a/prefsize_windows.go
+++ b/prefsize_windows.go
@@ -16,6 +16,7 @@ import (
// - http://msdn.microsoft.com/en-us/library/ms645502%28VS.85%29.aspx - the calculation needed
// - http://support.microsoft.com/kb/125681 - to get the base X and Y
// (thanks to http://stackoverflow.com/questions/58620/default-button-size)
+// For push buttons, date/time pickers, links (which we don't use), toolbars, and rebars (another type of toolbar), Common Controls version 6 provides convenient methods to use instead, falling back to the old way if it fails.
// As we are left with incomplete data, an arbitrary size will be chosen
const (
@@ -26,12 +27,14 @@ type dlgunits struct {
width int
height int
longest bool // TODO actually use this
+ getsize uintptr
}
var stdDlgSizes = [nctypes]dlgunits{
c_button: dlgunits{
width: 50,
height: 14,
+ getsize: _BCM_GETIDEALSIZE,
},
c_checkbox: dlgunits{
// widtdh is not defined here so assume longest
@@ -40,7 +43,7 @@ var stdDlgSizes = [nctypes]dlgunits{
},
c_combobox: dlgunits{
longest: true,
- height: 14,
+ height: 12, // from the Visual Studio 2012 offline docs's Win32 layout page; the online page above says 14
},
c_lineedit: dlgunits{
longest: true,
@@ -59,6 +62,7 @@ var stdDlgSizes = [nctypes]dlgunits{
width: 237, // the first reference says 107 also works; TODO decide which to use
height: 8,
},
+ // TODO area
}
var (
@@ -70,6 +74,21 @@ var (
// This function runs on uitask; call the functions directly.
func (s *sysData) preferredSize() (width int, height int) {
+ if msg := stdDlgSizes[s.ctype].getsize; msg != 0 {
+ var size _SIZE
+
+ r1, _, _ := _sendMessage.Call(
+ uintptr(s.hwnd),
+ msg,
+ uintptr(0),
+ uintptr(unsafe.Pointer(&size)))
+ if r1 != uintptr(_FALSE) { // success
+ return int(size.cx), int(size.cy)
+ }
+ // otherwise the message approach failed, so fall back to the regular approach
+ println("message failed; falling back")
+ }
+
var dc _HANDLE
var tm _TEXTMETRICS
var baseX, baseY int
@@ -126,6 +145,11 @@ func muldiv(ma int, mb int, div int) int {
return int(int32(r1))
}
+type _SIZE struct {
+ cx int32 // originally LONG
+ cy int32
+}
+
type _TEXTMETRICS struct {
tmHeight int32
tmAscent int32
diff --git a/todo.md b/todo.md
index 59cb551..0cacb2d 100644
--- a/todo.md
+++ b/todo.md
@@ -37,9 +37,8 @@ important things:
- 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
- LineEdit heights on Windows seem too big; either that or LineEdit, Button, and Label text is not vertically centered properly
- - are Checkboxes too small?
+ - are Checkboxes and Comboboxes too small?
- Cocoa has similar margining issues (like Comboboxes having margins)
- - on Windows 7 controls seem to use a slightly larger font than what the UI guidelines want? there really should have been a system call for this, Microsoft...
- oh, because message boxes use a different font on Windows 7 now, apparently?... Microsoft... TODO find out for sure
- 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