summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--redo/container_windows.go9
-rw-r--r--redo/label_windows.go2
-rw-r--r--redo/sizing_windows.c3
-rw-r--r--redo/winapi_windows.h2
-rw-r--r--redo/zz_test.go12
5 files changed, 18 insertions, 10 deletions
diff --git a/redo/container_windows.go b/redo/container_windows.go
index b484094..68cb59f 100644
--- a/redo/container_windows.go
+++ b/redo/container_windows.go
@@ -20,8 +20,9 @@ type sizing struct {
sizingbase
// for size calculations
- baseX C.int
- baseY C.int
+ baseX C.int
+ baseY C.int
+ internalLeading C.LONG
// for the actual resizing
// possibly the HDWP
@@ -105,12 +106,14 @@ const (
func (c *container) beginResize() (d *sizing) {
var baseX, baseY C.int
+ var internalLeading C.LONG
d = new(sizing)
- C.calculateBaseUnits(c.hwnd, &baseX, &baseY)
+ C.calculateBaseUnits(c.hwnd, &baseX, &baseY, &internalLeading)
d.baseX = baseX
d.baseY = baseY
+ d.internalLeading = internalLeading
if spaced {
d.xmargin = fromdlgunitsX(marginDialogUnits, d)
diff --git a/redo/label_windows.go b/redo/label_windows.go
index b61404a..561247c 100644
--- a/redo/label_windows.go
+++ b/redo/label_windows.go
@@ -81,6 +81,8 @@ func (l *label) commitResize(c *allocation, d *sizing) {
c.y += yoff
c.height -= yoff
}
+ c.y -= int(d.internalLeading)
+ c.height += int(d.internalLeading)
basecommitResize(l, c, d)
}
diff --git a/redo/sizing_windows.c b/redo/sizing_windows.c
index a2cd2cf..5f14b19 100644
--- a/redo/sizing_windows.c
+++ b/redo/sizing_windows.c
@@ -5,7 +5,7 @@
/* TODO figure out where these should go */
-void calculateBaseUnits(HWND hwnd, int *baseX, int *baseY)
+void calculateBaseUnits(HWND hwnd, int *baseX, int *baseY, LONG *internalLeading)
{
HDC dc;
HFONT prevFont;
@@ -21,6 +21,7 @@ void calculateBaseUnits(HWND hwnd, int *baseX, int *baseY)
xpanic("error getting text metrics for preferred size calculations", GetLastError());
*baseX = (int) tm.tmAveCharWidth; /* TODO not optimal; third reference below has better way */
*baseY = (int) tm.tmHeight;
+ *internalLeading = tm.tmInternalLeading;
if (SelectObject(dc, prevFont) != controlFont)
xpanic("error restoring previous font into device context after preferred size calculations", GetLastError());
if (ReleaseDC(hwnd, dc) == 0)
diff --git a/redo/winapi_windows.h b/redo/winapi_windows.h
index 9f67f95..c5a30fe 100644
--- a/redo/winapi_windows.h
+++ b/redo/winapi_windows.h
@@ -69,7 +69,7 @@ extern HBRUSH hollowBrush;
extern DWORD initWindows(char **);
/* sizing_windows.c */
-extern void calculateBaseUnits(HWND, int *, int *);
+extern void calculateBaseUnits(HWND, int *, int *, LONG *);
extern void moveWindow(HWND, int, int, int, int);
extern LONG controlTextLength(HWND, LPWSTR);
diff --git a/redo/zz_test.go b/redo/zz_test.go
index 61a7ca2..59f577b 100644
--- a/redo/zz_test.go
+++ b/redo/zz_test.go
@@ -87,15 +87,17 @@ func (tw *testwin) make(done chan struct{}) {
NewTextField(),
NewPasswordField(),
NewTable(reflect.TypeOf(struct{A,B,C int}{})),
- NewStandaloneLabel("hello"))
+ NewStandaloneLabel("hello ÉÀÔ"))
tw.t.Append("Pref Height", tw.sph)
stack1 := NewHorizontalStack(NewLabel("Test"), NewTextField())
stack1.SetStretchy(1)
- stack2 := NewHorizontalStack(NewLabel("Test 2"),
- NewTable(reflect.TypeOf(struct{A,B,C int}{})))
+ stack2 := NewHorizontalStack(NewLabel("ÉÀÔ"), NewTextField())
stack2.SetStretchy(1)
- tw.s = NewVerticalStack(stack1, stack2)
- tw.s.SetStretchy(1)
+ stack3 := NewHorizontalStack(NewLabel("Test 2"),
+ NewTable(reflect.TypeOf(struct{A,B,C int}{})))
+ stack3.SetStretchy(1)
+ tw.s = NewVerticalStack(stack1, stack2, stack3)
+ tw.s.SetStretchy(2)
tw.t.Append("Stack", tw.s)
tw.l = NewStandaloneLabel("hello")
tw.t.Append("Label", tw.l)