/*	Public domain	*/

/*
 * Provide function that prints the name of the passed windows message
 * and could further disect the messages further if needed.
 */


#define PVAL(a) \
	case (a) : \
		Debug(NULL, "%s", #a); \
		break;

static void
WGL_Print_WinMsg(AG_Window *win, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	Debug(NULL, "win %p, ", win);

	switch (uMsg) {
	PVAL(WM_NULL);
	PVAL(WM_CREATE);
	PVAL(WM_DESTROY);
	PVAL(WM_MOVE);
	PVAL(WM_SIZE);
	PVAL(WM_ACTIVATE);
	PVAL(WM_SETFOCUS);
	PVAL(WM_KILLFOCUS);
	PVAL(WM_ENABLE);
	PVAL(WM_SETREDRAW);
	PVAL(WM_SETTEXT);
	PVAL(WM_GETTEXT);
	PVAL(WM_GETTEXTLENGTH);
	PVAL(WM_PAINT);
	PVAL(WM_CLOSE);
	PVAL(WM_QUERYENDSESSION);
	PVAL(WM_QUIT);
	PVAL(WM_QUERYOPEN);
	PVAL(WM_ERASEBKGND);
	PVAL(WM_SYSCOLORCHANGE);
	PVAL(WM_ENDSESSION);
	PVAL(WM_SHOWWINDOW);
	PVAL(WM_SETTINGCHANGE);
	PVAL(WM_DEVMODECHANGE);
	PVAL(WM_ACTIVATEAPP);
	PVAL(WM_FONTCHANGE);
	PVAL(WM_TIMECHANGE);
	PVAL(WM_CANCELMODE);
	PVAL(WM_SETCURSOR);
	PVAL(WM_MOUSEACTIVATE);
	PVAL(WM_CHILDACTIVATE);
	PVAL(WM_QUEUESYNC);
	PVAL(WM_GETMINMAXINFO);
	PVAL(WM_PAINTICON);
	PVAL(WM_ICONERASEBKGND);
	PVAL(WM_NEXTDLGCTL);
	PVAL(WM_SPOOLERSTATUS);
	PVAL(WM_DRAWITEM);
	PVAL(WM_MEASUREITEM);
	PVAL(WM_DELETEITEM);
	PVAL(WM_VKEYTOITEM);
	PVAL(WM_CHARTOITEM);
	PVAL(WM_SETFONT);
	PVAL(WM_GETFONT);
	PVAL(WM_SETHOTKEY);
	PVAL(WM_GETHOTKEY);
	PVAL(WM_QUERYDRAGICON);
	PVAL(WM_COMPAREITEM);
	PVAL(WM_COMPACTING);
	PVAL(WM_COMMNOTIFY);
	PVAL(WM_WINDOWPOSCHANGING);
	PVAL(WM_WINDOWPOSCHANGED);
	PVAL(WM_POWER);
	PVAL(WM_COPYDATA);
	PVAL(WM_CANCELJOURNAL);
	PVAL(WM_NOTIFY);
	PVAL(WM_INPUTLANGCHANGEREQUEST);
	PVAL(WM_INPUTLANGCHANGE);
	PVAL(WM_TCARD);
	PVAL(WM_HELP);
	PVAL(WM_USERCHANGED);
	PVAL(WM_NOTIFYFORMAT);
	PVAL(WM_CONTEXTMENU);
	PVAL(WM_STYLECHANGING);
	PVAL(WM_STYLECHANGED);
	PVAL(WM_DISPLAYCHANGE);
	PVAL(WM_GETICON);
	PVAL(WM_SETICON);
	PVAL(WM_NCCREATE);
	PVAL(WM_NCDESTROY);
	PVAL(WM_NCCALCSIZE);
	PVAL(WM_NCHITTEST);
	PVAL(WM_NCPAINT);
	PVAL(WM_NCACTIVATE);
	PVAL(WM_GETDLGCODE);
	PVAL(WM_SYNCPAINT);
	PVAL(WM_NCMOUSEMOVE);
	PVAL(WM_NCLBUTTONDOWN);
	PVAL(WM_NCLBUTTONUP);
	PVAL(WM_NCLBUTTONDBLCLK);
	PVAL(WM_NCRBUTTONDOWN);
	PVAL(WM_NCRBUTTONUP);
	PVAL(WM_NCRBUTTONDBLCLK);
	PVAL(WM_NCMBUTTONDOWN);
	PVAL(WM_NCMBUTTONUP);
	PVAL(WM_NCMBUTTONDBLCLK);
	PVAL(WM_KEYDOWN);
	PVAL(WM_KEYUP);
	PVAL(WM_CHAR);
	PVAL(WM_DEADCHAR);
	PVAL(WM_SYSKEYDOWN);
	PVAL(WM_SYSKEYUP);
	PVAL(WM_SYSCHAR);
	PVAL(WM_SYSDEADCHAR);
	PVAL(WM_KEYLAST);
	PVAL(WM_IME_STARTCOMPOSITION);
	PVAL(WM_IME_ENDCOMPOSITION);
	PVAL(WM_IME_COMPOSITION);
	PVAL(WM_INITDIALOG);
	PVAL(WM_COMMAND);
	PVAL(WM_SYSCOMMAND);
	PVAL(WM_TIMER);
	PVAL(WM_HSCROLL);
	PVAL(WM_VSCROLL);
	PVAL(WM_INITMENU);
	PVAL(WM_INITMENUPOPUP);
	PVAL(WM_MENUSELECT);
	PVAL(WM_MENUCHAR);
	PVAL(WM_ENTERIDLE);
	PVAL(WM_CTLCOLORMSGBOX);
	PVAL(WM_CTLCOLOREDIT);
	PVAL(WM_CTLCOLORLISTBOX);
	PVAL(WM_CTLCOLORBTN);
	PVAL(WM_CTLCOLORDLG);
	PVAL(WM_CTLCOLORSCROLLBAR);
	PVAL(WM_CTLCOLORSTATIC);
	PVAL(WM_MOUSEMOVE);
	PVAL(WM_LBUTTONDOWN);
	PVAL(WM_LBUTTONUP);
	PVAL(WM_LBUTTONDBLCLK);
	PVAL(WM_RBUTTONDOWN);
	PVAL(WM_RBUTTONUP);
	PVAL(WM_RBUTTONDBLCLK);
	PVAL(WM_MBUTTONDOWN);
	PVAL(WM_MBUTTONUP);
	PVAL(WM_MBUTTONDBLCLK);
	PVAL(WM_MOUSEWHEEL);
	PVAL(WM_PARENTNOTIFY);
	PVAL(WM_ENTERMENULOOP);
	PVAL(WM_EXITMENULOOP);
	PVAL(WM_NEXTMENU);
	PVAL(WM_SIZING);
	PVAL(WM_CAPTURECHANGED);
	PVAL(WM_MOVING);
	PVAL(WM_POWERBROADCAST);
	PVAL(WM_DEVICECHANGE);
	PVAL(WM_MDICREATE);
	PVAL(WM_MDIDESTROY);
	PVAL(WM_MDIACTIVATE);
	PVAL(WM_MDIRESTORE);
	PVAL(WM_MDINEXT);
	PVAL(WM_MDIMAXIMIZE);
	PVAL(WM_MDITILE);
	PVAL(WM_MDICASCADE);
	PVAL(WM_MDIICONARRANGE);
	PVAL(WM_MDIGETACTIVE);
	PVAL(WM_MDISETMENU);
	PVAL(WM_ENTERSIZEMOVE);
	PVAL(WM_EXITSIZEMOVE);
	PVAL(WM_DROPFILES);
	PVAL(WM_MDIREFRESHMENU);
	PVAL(WM_MOUSEHOVER);
	PVAL(WM_IME_SETCONTEXT);
	PVAL(WM_IME_NOTIFY);
	PVAL(WM_IME_CONTROL);
	PVAL(WM_IME_COMPOSITIONFULL);
	PVAL(WM_IME_SELECT);
	PVAL(WM_IME_CHAR);
	PVAL(WM_IME_KEYDOWN);
	PVAL(WM_IME_KEYUP);
	PVAL(WM_MOUSELEAVE);
	PVAL(WM_CUT);
	PVAL(WM_COPY);
	PVAL(WM_PASTE);
	PVAL(WM_CLEAR);
	PVAL(WM_UNDO);
	PVAL(WM_RENDERFORMAT);
	PVAL(WM_RENDERALLFORMATS);
	PVAL(WM_DESTROYCLIPBOARD);
	PVAL(WM_DRAWCLIPBOARD);
	PVAL(WM_PAINTCLIPBOARD);
	PVAL(WM_VSCROLLCLIPBOARD);
	PVAL(WM_SIZECLIPBOARD);
	PVAL(WM_ASKCBFORMATNAME);
	PVAL(WM_CHANGECBCHAIN);
	PVAL(WM_HSCROLLCLIPBOARD);
	PVAL(WM_QUERYNEWPALETTE);
	PVAL(WM_PALETTEISCHANGING);
	PVAL(WM_PALETTECHANGED);
	PVAL(WM_HOTKEY);
	PVAL(WM_PRINT);
	PVAL(WM_PRINTCLIENT);
	PVAL(WM_HANDHELDFIRST);
	PVAL(WM_HANDHELDLAST);
	PVAL(WM_AFXFIRST);
	PVAL(WM_AFXLAST);
	PVAL(WM_PENWINFIRST);
	PVAL(WM_PENWINLAST);
	PVAL(WM_USER);
	default:
		Debug(NULL, "UNKNOWN 0x%04X", uMsg);
	}
	Debug(NULL, "\n");
}

#undef PVAL


