summaryrefslogtreecommitdiff
path: root/alf/alf.h
diff options
context:
space:
mode:
Diffstat (limited to 'alf/alf.h')
-rw-r--r--alf/alf.h125
1 files changed, 125 insertions, 0 deletions
diff --git a/alf/alf.h b/alf/alf.h
new file mode 100644
index 0000000..d50bd67
--- /dev/null
+++ b/alf/alf.h
@@ -0,0 +1,125 @@
+#pragma once
+
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct {
+ int dpi;
+ LOGFONT lfMessageFont;
+ HFONT hMessageFont;
+} ALFWindowFonts;
+
+typedef struct {
+ void (*create)(void * /*closure*/, HWND /*window*/);
+ void (*destroy)(void * /*closure*/, HWND /*window*/);
+ BOOL (*close)(void * /*closure*/, HWND /*window*/);
+ void (*postdestroy)(void * /*closure*/);
+ void (*updatefonts)(void * /*closure*/, HWND /*window*/, const ALFWindowFonts *fonts);
+ LRESULT (*message)(void * /*closure*/, HWND, UINT, WPARAM, LPARAM);
+ LRESULT (*command)(void * /*closure*/, HWND /*window*/, UINT /*sourceid*/, UINT /*notificationcode*/, LPARAM);
+ LRESULT (*notify)(void * /*closure*/, HWND /*window*/, WPARAM /*sourceid*/, NMHDR *);
+} ALFWindowVTable;
+
+// layout flags
+#define ALF_QUERYSIZE 0x01
+#define ALF_HEXPAND 0x02
+#define ALF_VEXPAND 0x04
+#define ALF_MESSAGEFONT 0x08
+
+// messages
+#define ALF_WM__BASE 0x2800
+#define ALF_WM_QUERYSIZE (ALF_WM__BASE + 1)
+#define ALF_WM_APPLYLAYOUT (ALF_WM__BASE + 2)
+#define ALF_WM_UPDATEFONTS (ALF_WM__BASE + 3)
+#define ALF_WM_ADDWIDGET (ALF_WM__BASE + 4)
+#define ALF_WM_WIDGETBYID (ALF_WM__BASE + 5)
+#define ALF_WM_REMOVEWIDGET (ALF_WM__BASE + 6)
+#define ALF_WM_SETMODALRESULT (ALF_WM__BASE + 7)
+#define ALF_WM_GETMODALRESULT (ALF_WM__BASE + 8)
+#define ALF_WM_CENTIPOINTTOPX (ALF_WM__BASE + 9)
+
+
+typedef struct {
+ const WCHAR *className;
+ UINT classStyle;
+ ALFWindowVTable vtbl;
+} ALFWindowClassParams;
+
+typedef struct {
+ void *closure;
+ HWND hwndParent;
+ UINT windowStyle;
+ UINT windowExStyle;
+} ALFWindowInstanceParams;
+
+typedef struct {
+ HWND hwnd;
+ UINT x;
+ UINT y;
+ UINT width;
+ UINT height;
+ DWORD flags;
+ UINT margins[4];
+} ALFAddWidgetParams;
+
+LPTSTR
+ALF_RegisterWindowClass(HINSTANCE hInstance, const ALFWindowClassParams *params);
+
+void
+ALF_UnregisterWindowClass(HINSTANCE hInstance, LPCTSTR className);
+
+HWND
+ALF_InstantiateWindow(HINSTANCE hInstance, LPCTSTR className, const ALFWindowInstanceParams *params);
+
+int
+ALF_CentipointsToPixels(HWND win, int cptValue);
+
+LRESULT
+ALF_DefWindowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
+
+HWND
+ALF_AddLabel(HWND win, int id, UINT x, UINT y, const WCHAR *text);
+
+HWND
+ALF_AddEdit(HWND win, int id, UINT x, UINT y, const WCHAR *text);
+
+HWND
+ALF_AddButton(HWND win, int id, UINT x, UINT y, const WCHAR *text);
+
+void
+ALF_DestroyWidget(HWND win, int id);
+
+void
+ALF_AddWidget(HWND win, UINT x, UINT y, HWND widget, UINT cptWidth, UINT cptHeight, DWORD flags);
+
+void
+ALF_AddWidgetEx(HWND win, const ALFAddWidgetParams *params);
+
+HWND
+ALF_WidgetHwndById(HWND win, int id);
+
+void
+ALF_RecalculateLayout(HWND win);
+
+void
+ALF_UpdateFonts(HWND win);
+
+void
+ALF_ResizeWindow(HWND win, UINT cptWidth, UINT cptHeight);
+
+int
+ALF_ShowModal(HWND win);
+
+void
+ALF_SetModalResult(HWND win, int result);
+
+int
+ALF_GetModalResult(HWND win);
+
+#ifdef __cplusplus
+} // extern C
+#endif