summaryrefslogtreecommitdiff
path: root/wintable/new/coord.h
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2014-12-08 16:23:55 -0500
committerPietro Gagliardi <[email protected]>2014-12-08 16:23:55 -0500
commit59054c8932ef3eb75f3b676eee1674219ee150f6 (patch)
treef221881ad6ca620d6a990e19f20c8488965ff816 /wintable/new/coord.h
parent6271fc941aecccbd61b8a2ed68139148f1040225 (diff)
Readded rowHeight(). Also tested font helper functions.
Diffstat (limited to 'wintable/new/coord.h')
-rw-r--r--wintable/new/coord.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/wintable/new/coord.h b/wintable/new/coord.h
index 1814e87..fff807d 100644
--- a/wintable/new/coord.h
+++ b/wintable/new/coord.h
@@ -29,3 +29,31 @@ static BOOL rowColumnToClientCoord(struct table *t, rowcol rc, struct POINT *pt)
}
// TODO idealCoordToRowColumn/rowColumnToIdealCoord?
+
+// TODO find a better place for this
+static LONG rowHeight(struct table *t, HDC dc, BOOL select)
+{
+ BOOL release;
+ HFONT prevfont, newfont;
+ TEXTMETRICW tm;
+
+ release = FALSE;
+ if (dc == NULL) {
+ dc = GetDC(t->hwnd);
+ if (dc == NULL)
+ panic("error getting Table DC for rowHeight()");
+ release = TRUE;
+ }
+ if (select)
+ prevfont = selectFont(t, dc, &newfont);
+ if (GetTextMetricsW(dc, &tm) == 0)
+ panic("error getting text metrics for rowHeight()");
+ if (select)
+ deselectFont(dc, prevfont, newfont);
+ if (release)
+ if (ReleaseDC(t->hwnd, dc) == 0)
+ panic("error releasing Table DC for rowHeight()");
+ return tm.tmHeight;
+}
+
+#define rowht(t) rowHeight(t, NULL, TRUE)