summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--redo/controls_windows.c5
-rw-r--r--redo/controls_windows.go1
-rw-r--r--redo/init_windows.c26
-rw-r--r--redo/sizing_windows.c3
-rw-r--r--redo/winapi_windows.h6
5 files changed, 38 insertions, 3 deletions
diff --git a/redo/controls_windows.c b/redo/controls_windows.c
index 64bf273..c660bd7 100644
--- a/redo/controls_windows.c
+++ b/redo/controls_windows.c
@@ -31,6 +31,11 @@ void controlSetParent(HWND control, HWND parent)
xpanic("error changing control parent", GetLastError());
}
+void controlSetControlFont(HWND which)
+{
+ SendMessageW(which, WM_SETFONT, (WPARAM) controlFont, TRUE);
+}
+
/*
all controls that have events receive the events themselves through subclasses
to do this, all windows (including the message-only window; see http://support.microsoft.com/default.aspx?scid=KB;EN-US;Q104069) forward WM_COMMAND to each control with this function
diff --git a/redo/controls_windows.go b/redo/controls_windows.go
index ec2f827..b9ece44 100644
--- a/redo/controls_windows.go
+++ b/redo/controls_windows.go
@@ -67,6 +67,7 @@ func newButton(text string) *Request {
C.BS_PUSHBUTTON | C.WS_TABSTOP,
0)
C.setWindowText(w.hwnd, toUTF16(text))
+ C.controlSetControlFont(w.hwnd)
b := &button{
widgetbase: w,
clicked: newEvent(),
diff --git a/redo/init_windows.c b/redo/init_windows.c
index d3771e0..343b9d4 100644
--- a/redo/init_windows.c
+++ b/redo/init_windows.c
@@ -8,9 +8,16 @@ int nCmdShow;
HICON hDefaultIcon;
HCURSOR hArrowCursor;
+HFONT controlFont;
+HFONT titleFont;
+HFONT smallTitleFont;
+HFONT menubarFont;
+HFONT statusbarFont;
+
DWORD initWindows(char **errmsg)
{
STARTUPINFOW si;
+ NONCLIENTMETRICSW ncm;
/* WinMain() parameters */
hInstance = GetModuleHandleW(NULL);
@@ -35,5 +42,24 @@ DWORD initWindows(char **errmsg)
return GetLastError();
}
+ /* standard fonts */
+#define GETFONT(l, f, n) l = CreateFontIndirectW(&ncm.f); \
+ if (l == NULL) { \
+ *errmsg = "error loading " n " font"; \
+ return GetLastError(); \
+ }
+
+ ZeroMemory(&ncm, sizeof (NONCLIENTMETRICSW));
+ ncm.cbSize = sizeof (NONCLIENTMETRICSW);
+ if (SystemParametersInfoW(SPI_GETNONCLIENTMETRICS, sizeof (NONCLIENTMETRICSW), &ncm, sizeof (NONCLIENTMETRICSW)) == 0) {
+ *errmsg = "error getting non-client metrics parameters";
+ return GetLastError();
+ }
+ GETFONT(controlFont, lfMessageFont, "control");
+ GETFONT(titleFont, lfCaptionFont, "titlebar");
+ GETFONT(smallTitleFont, lfSmCaptionFont, "small title bar");
+ GETFONT(menubarFont, lfMenuFont, "menu bar");
+ GETFONT(statusbarFont, lfStatusFont, "status bar");
+
return 0;
}
diff --git a/redo/sizing_windows.c b/redo/sizing_windows.c
index 2b0357d..5589ddd 100644
--- a/redo/sizing_windows.c
+++ b/redo/sizing_windows.c
@@ -10,12 +10,9 @@ HDC getDC(HWND hwnd)
dc = GetDC(hwnd);
if (dc == NULL)
xpanic("error getting DC for preferred size calculations", GetLastError());
-/* TODO */
/* TODO save for restoring later */
-/*
if (SelectObject(dc, controlFont) == NULL)
xpanic("error loading control font into device context for preferred size calculation", GetLastError());
-*/
return dc;
}
diff --git a/redo/winapi_windows.h b/redo/winapi_windows.h
index 9d75af4..0a8c19e 100644
--- a/redo/winapi_windows.h
+++ b/redo/winapi_windows.h
@@ -40,6 +40,7 @@ extern LRESULT (*WINAPI fv_DefSubclassProc)(HWND, UINT, WPARAM, LPARAM);
/* controls_windows.c */
extern HWND newWidget(LPCWSTR, DWORD, DWORD);
extern void controlSetParent(HWND, HWND);
+extern void controlSetControlFont(HWND);
extern LRESULT forwardCommand(HWND, UINT, WPARAM, LPARAM);
extern void setButtonSubclass(HWND, void *);
@@ -48,6 +49,11 @@ extern HINSTANCE hInstance;
extern int nCmdShow;
extern HICON hDefaultIcon;
extern HCURSOR hArrowCursor;
+extern HFONT controlFont;
+extern HFONT titleFont;
+extern HFONT smallTitleFont;
+extern HFONT menubarFont;
+extern HFONT statusbarFont;
extern DWORD initWindows(char **);
/* sizing_windows.c */