1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
|
#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
#define ALF_APPLYSIZE 0x10
// 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)
#define ALF_WM_SETFOCUS (ALF_WM__BASE + 10)
#define ALF_WM_GETAPPLICATION (ALF_WM__BASE + 11)
#define ALF_WM_APPLYSIZE (ALF_WM__BASE + 12)
typedef struct {
const WCHAR *className;
UINT classStyle;
ALFWindowVTable vtbl;
} ALFWindowClassParams;
typedef struct {
HWND hwnd;
UINT x;
UINT y;
UINT width;
UINT height;
DWORD flags;
UINT margins[4];
} ALFAddWidgetParams;
typedef struct ALFAppPriv *ALFAPP;
typedef enum {
ALF_DPI_AWARENESS_UNAWARE,
ALF_DPI_AWARENESS_SYSTEM_AWARE,
ALF_DPI_AWARENESS_PER_MONITOR_AWARE_V2
} ALFDpiAwareness;
void
ALF_SetDpiAwareness(ALFDpiAwareness awareness);
ALFAPP
ALF_CreateApplication(HINSTANCE hInstance);
void
ALF_TeardownApplication(ALFAPP app);
LPTSTR
ALF_RegisterWindowClass(ALFAPP app, const ALFWindowClassParams *params);
void
ALF_UnregisterWindowClass(ALFAPP app, LPCTSTR className);
HWND
ALF_InstantiateWindow(ALFAPP app, LPCTSTR className, HWND hwndParent, void *closure);
ALFAPP
ALF_ApplicationFromWindow(HWND hwnd);
int
ALF_CentipointsToPixels(HWND win, int cptValue);
LRESULT
ALF_DefWindowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
HWND
ALF_AddLabel(HWND win, WORD id, UINT x, UINT y, const WCHAR *text);
HWND
ALF_AddEdit(HWND win, WORD id, UINT x, UINT y, const WCHAR *text);
HWND
ALF_AddButton(HWND win, WORD id, UINT x, UINT y, const WCHAR *text);
void
ALF_SetDefaultButton(HWND win, WORD id);
void
ALF_DestroyWidget(HWND win, WORD 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, WORD id);
void
ALF_RecalculateLayout(HWND win);
void
ALF_UpdateFonts(HWND win);
void
ALF_ResizeWindow(HWND win, int cptWidth, int cptHeight);
void
ALF_ResizeWindowPx(HWND win, int pxWidth, int pxHeight);
int
ALF_ShowModal(HWND win);
void
ALF_SetModalResult(HWND win, int result);
int
ALF_GetModalResult(HWND win);
#ifdef __cplusplus
} // extern C
#endif
|