summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--alf/alf.h4
-rw-r--r--alf/alflayout.cpp2
-rw-r--r--alf/alfpanel.cpp110
3 files changed, 113 insertions, 3 deletions
diff --git a/alf/alf.h b/alf/alf.h
index d264e93..79883be 100644
--- a/alf/alf.h
+++ b/alf/alf.h
@@ -32,8 +32,8 @@ typedef struct {
#define ALF_MESSAGEFONT 0x10
#define ALF_STATUSFONT 0x20
#define ALF_ICONTITLEFONT 0x40
-// special value, means "send ALF_WM_APPLYFONTS message with full fonts struct"
-#define ALF_ALLFONTS (ALF_MESSAGEFONT | ALF_STATUSFONT | ALF_ICONTITLEFONT)
+// sends a ALF_WM_APPLYFONTS message to the widget with ALFWindowFonts* lparam
+#define ALF_SENDAPPLYFONTS 0x80
// messages
#define ALF_WM__BASE 0x2800
diff --git a/alf/alflayout.cpp b/alf/alflayout.cpp
index caf9857..cb89965 100644
--- a/alf/alflayout.cpp
+++ b/alf/alflayout.cpp
@@ -28,7 +28,7 @@ ALF_ApplyFontForWidget(ALFWidgetPriv *widget, const ALFWindowFonts *fonts)
// least the commctl32 V5 static control doesn't do it.
InvalidateRect(widget->hwnd, NULL, TRUE);
}
- if ((widget->flags & ALF_ALLFONTS) == ALF_ALLFONTS) {
+ if (widget->flags & ALF_SENDAPPLYFONTS) {
SendMessage(widget->hwnd, ALF_WM_APPLYFONTS, 0, (LPARAM)fonts);
}
}
diff --git a/alf/alfpanel.cpp b/alf/alfpanel.cpp
new file mode 100644
index 0000000..74db788
--- /dev/null
+++ b/alf/alfpanel.cpp
@@ -0,0 +1,110 @@
+#include "alfpriv.h"
+
+typedef struct {
+ ALFAPP app;
+ ALFLayout layout;
+} ALFPanelPriv;
+
+static void
+ALF_Panel_IntializePriv(ALFPanelPriv *priv, ALFAPP app)
+{
+ priv->app = app;
+ ALF_Layout_Init(&priv->layout);
+}
+
+static void
+ALF_Panel_ClearPriv(ALFPanelPriv *priv)
+{
+ ALF_Layout_Clear(&priv->layout);
+}
+
+static LRESULT WINAPI
+ALF__PanelWindowProc(HWND window, UINT msg, WPARAM wparam, LPARAM lparam)
+{
+ if (msg == WM_NCCREATE) {
+ ALFPanelPriv *p = (ALFPanelPriv*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(ALFPanelPriv));
+
+ ALFAPP app = (ALFAPP)(((CREATESTRUCT*)lparam)->lpCreateParams);
+ ALF_Panel_IntializePriv(p, app);
+
+ SetWindowLongPtr(window, 0, (LONG_PTR)p);
+ }
+
+ ALFPanelPriv *priv = (ALFPanelPriv *)GetWindowLongPtr(window, 0);
+
+ if (msg == WM_NCDESTROY) {
+ ALF_Panel_ClearPriv(priv);
+ HeapFree(GetProcessHeap(), 0, priv);
+ SetWindowLongPtr(window, 0, 0);
+ }
+
+ if (ALF_ShouldMessageBubble(window, msg, wparam, lparam))
+ return SendMessage(GetParent(window), msg, wparam, lparam);
+
+ if (msg == WM_SIZE) {
+ ALF_Layout_Apply(&priv->layout, window);
+ }
+
+ LRESULT ret = 0;
+ if (ALF_Layout_HandleMessage(&priv->layout, window, msg, wparam, lparam, &ret))
+ return ret;
+
+ return DefWindowProc(window, msg, wparam, lparam);
+}
+
+void
+ALF_RegisterPanelClass(ALFAPP app)
+{
+ WNDCLASS cls;
+ ZeroMemory(&cls, sizeof(cls));
+
+ TCHAR classNameBuf[256];
+ ALF_BuildRandomClassName(app, TEXT("ALFPanel."), classNameBuf);
+
+ 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 = ALF__PanelWindowProc;
+
+ ATOM classatom = RegisterClass(&cls);
+ if (!classatom)
+ MessageBox(NULL, TEXT("FATAL: Could not register Combo class"), NULL, MB_OK);
+
+ app->panelClass = MAKEINTATOM(classatom);
+}
+
+HWND
+ALF_AddPanel(HWND parent, WORD id, UINT x, UINT y)
+{
+ ALFAPP app = ALF_ApplicationFromWindow(parent);
+
+ HWND hwndPanel = CreateWindowEx(WS_EX_CONTROLPARENT,
+ app->panelClass,
+ 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 = hwndPanel;
+ p.x = x;
+ p.y = y;
+ p.width = 0;
+ p.height = 0;
+ p.flags = ALF_QUERYSIZE | ALF_SENDAPPLYFONTS;
+
+ ALF_AddWidgetEx(parent, &p);
+
+ return hwndPanel;
+}