Added (and applied) standard Windows fonts.
This commit is contained in:
parent
489ce0a053
commit
f64f2781ce
|
@ -31,6 +31,11 @@ void controlSetParent(HWND control, HWND parent)
|
||||||
xpanic("error changing control parent", GetLastError());
|
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
|
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
|
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
|
||||||
|
|
|
@ -67,6 +67,7 @@ func newButton(text string) *Request {
|
||||||
C.BS_PUSHBUTTON | C.WS_TABSTOP,
|
C.BS_PUSHBUTTON | C.WS_TABSTOP,
|
||||||
0)
|
0)
|
||||||
C.setWindowText(w.hwnd, toUTF16(text))
|
C.setWindowText(w.hwnd, toUTF16(text))
|
||||||
|
C.controlSetControlFont(w.hwnd)
|
||||||
b := &button{
|
b := &button{
|
||||||
widgetbase: w,
|
widgetbase: w,
|
||||||
clicked: newEvent(),
|
clicked: newEvent(),
|
||||||
|
|
|
@ -8,9 +8,16 @@ int nCmdShow;
|
||||||
HICON hDefaultIcon;
|
HICON hDefaultIcon;
|
||||||
HCURSOR hArrowCursor;
|
HCURSOR hArrowCursor;
|
||||||
|
|
||||||
|
HFONT controlFont;
|
||||||
|
HFONT titleFont;
|
||||||
|
HFONT smallTitleFont;
|
||||||
|
HFONT menubarFont;
|
||||||
|
HFONT statusbarFont;
|
||||||
|
|
||||||
DWORD initWindows(char **errmsg)
|
DWORD initWindows(char **errmsg)
|
||||||
{
|
{
|
||||||
STARTUPINFOW si;
|
STARTUPINFOW si;
|
||||||
|
NONCLIENTMETRICSW ncm;
|
||||||
|
|
||||||
/* WinMain() parameters */
|
/* WinMain() parameters */
|
||||||
hInstance = GetModuleHandleW(NULL);
|
hInstance = GetModuleHandleW(NULL);
|
||||||
|
@ -35,5 +42,24 @@ DWORD initWindows(char **errmsg)
|
||||||
return GetLastError();
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,12 +10,9 @@ HDC getDC(HWND hwnd)
|
||||||
dc = GetDC(hwnd);
|
dc = GetDC(hwnd);
|
||||||
if (dc == NULL)
|
if (dc == NULL)
|
||||||
xpanic("error getting DC for preferred size calculations", GetLastError());
|
xpanic("error getting DC for preferred size calculations", GetLastError());
|
||||||
/* TODO */
|
|
||||||
/* TODO save for restoring later */
|
/* TODO save for restoring later */
|
||||||
/*
|
|
||||||
if (SelectObject(dc, controlFont) == NULL)
|
if (SelectObject(dc, controlFont) == NULL)
|
||||||
xpanic("error loading control font into device context for preferred size calculation", GetLastError());
|
xpanic("error loading control font into device context for preferred size calculation", GetLastError());
|
||||||
*/
|
|
||||||
return dc;
|
return dc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,7 @@ extern LRESULT (*WINAPI fv_DefSubclassProc)(HWND, UINT, WPARAM, LPARAM);
|
||||||
/* controls_windows.c */
|
/* controls_windows.c */
|
||||||
extern HWND newWidget(LPCWSTR, DWORD, DWORD);
|
extern HWND newWidget(LPCWSTR, DWORD, DWORD);
|
||||||
extern void controlSetParent(HWND, HWND);
|
extern void controlSetParent(HWND, HWND);
|
||||||
|
extern void controlSetControlFont(HWND);
|
||||||
extern LRESULT forwardCommand(HWND, UINT, WPARAM, LPARAM);
|
extern LRESULT forwardCommand(HWND, UINT, WPARAM, LPARAM);
|
||||||
extern void setButtonSubclass(HWND, void *);
|
extern void setButtonSubclass(HWND, void *);
|
||||||
|
|
||||||
|
@ -48,6 +49,11 @@ extern HINSTANCE hInstance;
|
||||||
extern int nCmdShow;
|
extern int nCmdShow;
|
||||||
extern HICON hDefaultIcon;
|
extern HICON hDefaultIcon;
|
||||||
extern HCURSOR hArrowCursor;
|
extern HCURSOR hArrowCursor;
|
||||||
|
extern HFONT controlFont;
|
||||||
|
extern HFONT titleFont;
|
||||||
|
extern HFONT smallTitleFont;
|
||||||
|
extern HFONT menubarFont;
|
||||||
|
extern HFONT statusbarFont;
|
||||||
extern DWORD initWindows(char **);
|
extern DWORD initWindows(char **);
|
||||||
|
|
||||||
/* sizing_windows.c */
|
/* sizing_windows.c */
|
||||||
|
|
Loading…
Reference in New Issue