summaryrefslogtreecommitdiff
path: root/alf
diff options
context:
space:
mode:
authorJonas Kümmerlin <jonas@kuemmerlin.eu>2019-01-09 20:52:10 +0100
committerJonas Kümmerlin <jonas@kuemmerlin.eu>2019-01-09 20:52:10 +0100
commit9279dd93c3997a51b227d3380b4da659fcbdff96 (patch)
tree4b2b5880e5062a829e1c3018718b10154af54ebc /alf
parenteb706aae8bf5659a8aae37db31f88c3b605b8b1f (diff)
add spacer widget
Diffstat (limited to 'alf')
-rw-r--r--alf/alf.cpp2
-rw-r--r--alf/alf.h4
-rw-r--r--alf/alfpriv.h4
-rw-r--r--alf/alfspacer.cpp58
4 files changed, 68 insertions, 0 deletions
diff --git a/alf/alf.cpp b/alf/alf.cpp
index 64b4cc4..6f8d28a 100644
--- a/alf/alf.cpp
+++ b/alf/alf.cpp
@@ -343,6 +343,7 @@ ALF_CreateApplication(HINSTANCE hInstance)
ALF_RegisterComboClass(app);
ALF_RegisterPanelClass(app);
+ ALF_RegisterSpacerClass(app);
return app;
}
@@ -352,6 +353,7 @@ ALF_TeardownApplication(ALFAPP app)
{
UnregisterClass(app->comboClass, app->hInstance);
UnregisterClass(app->panelClass, app->hInstance);
+ UnregisterClass(app->spacerClass, app->hInstance);
HeapFree(GetProcessHeap(), 0, app);
}
diff --git a/alf/alf.h b/alf/alf.h
index 79883be..0c32a20 100644
--- a/alf/alf.h
+++ b/alf/alf.h
@@ -250,6 +250,10 @@ ALF_ComboBoxSetText(HWND combo, const TCHAR *text);
HWND
ALF_AddPanel(HWND parent, WORD id, UINT x, UINT y);
+// spacer
+HWND
+ALF_AddSpacer(HWND parent, WORD id, UINT x, UINT y, UINT cptWidth, UINT cptHeight, DWORD layoutFlags);
+
#ifdef __cplusplus
} // extern C
#endif
diff --git a/alf/alfpriv.h b/alf/alfpriv.h
index ec7a447..775d421 100644
--- a/alf/alfpriv.h
+++ b/alf/alfpriv.h
@@ -32,6 +32,7 @@ struct ALFAppPriv {
HINSTANCE hInstance;
TCHAR *comboClass;
TCHAR *panelClass;
+ TCHAR *spacerClass;
};
int
@@ -50,6 +51,9 @@ void
ALF_RegisterPanelClass(ALFAPP app);
void
+ALF_RegisterSpacerClass(ALFAPP app);
+
+void
ALF_BuildRandomClassName(const TCHAR *prefix, TCHAR *buf, DWORD cchBuf);
BOOL
diff --git a/alf/alfspacer.cpp b/alf/alfspacer.cpp
new file mode 100644
index 0000000..545dfbc
--- /dev/null
+++ b/alf/alfspacer.cpp
@@ -0,0 +1,58 @@
+#include "alfpriv.h"
+
+void
+ALF_RegisterSpacerClass(ALFAPP app)
+{
+ WNDCLASS cls;
+ ZeroMemory(&cls, sizeof(cls));
+
+ TCHAR classNameBuf[256];
+ ALF_BuildRandomClassName(TEXT("ALFSpacer"), classNameBuf, 256);
+
+ cls.hInstance = app->hInstance;
+ cls.hCursor = LoadCursor(NULL, (LPTSTR)IDC_ARROW);
+ if (LOBYTE(LOWORD(GetVersion())) >= 4) {
+ cls.hbrBackground = (HBRUSH)(COLOR_BTNFACE+1);
+ } else {
+ // NT 3.x has white dialog backgrounds
+ cls.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
+ }
+ cls.lpszClassName = classNameBuf;
+ cls.cbWndExtra = sizeof(void*);
+ cls.lpfnWndProc = DefWindowProc;
+
+ ATOM classatom = RegisterClass(&cls);
+ if (!classatom)
+ MessageBox(NULL, TEXT("FATAL: Could not register spacer class"), NULL, MB_OK);
+
+ app->spacerClass = MAKEINTATOM(classatom);
+}
+
+HWND
+ALF_AddSpacer(HWND parent, WORD id, UINT x, UINT y, UINT cptWidth, UINT cptHeight, DWORD layoutFlags)
+{
+ ALFAPP app = ALF_ApplicationFromWindow(parent);
+
+ HWND hwndSpacer = CreateWindowEx(0,
+ app->spacerClass,
+ TEXT(""),
+ WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN,
+ 0, 0, 0, 0,
+ parent,
+ (HMENU)(int)id,
+ (HINSTANCE)GetWindowLongPtr(parent, GWLP_HINSTANCE),
+ (void*)app);
+
+ ALFWidgetLayoutParams p;
+ ZeroMemory(&p, sizeof(p));
+ p.hwnd = hwndSpacer;
+ p.x = x;
+ p.y = y;
+ p.width = cptWidth;
+ p.height = cptHeight;
+ p.flags = layoutFlags;
+
+ ALF_AddWidgetEx(parent, &p);
+
+ return hwndSpacer;
+}