summaryrefslogtreecommitdiff
path: root/alf/alfspacer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'alf/alfspacer.cpp')
-rw-r--r--alf/alfspacer.cpp58
1 files changed, 58 insertions, 0 deletions
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;
+}