diff --git a/redo/ui_windows.h b/redo/ui_windows.h index b16cbc11..e651bbb7 100644 --- a/redo/ui_windows.h +++ b/redo/ui_windows.h @@ -7,8 +7,10 @@ This file assumes that you have included and "ui.h" beforehand. It p #ifndef __UI_UI_WINDOWS_H__ #define __UI_UI_WINDOWS_H__ -// TODO write comments for these +// This creates a HWND compatible with libui. _UI_EXTERN HWND uiWindowsUtilCreateControlHWND(DWORD dwExStyle, LPCWSTR lpClassName, LPCWSTR lpWindowName, DWORD dwStyle, HINSTANCE hInstance, LPVOID lpParam, BOOL useStandardControlFont); + +// These provide single-HWND implementations of uiControl methods you can use in yours. _UI_EXTERN void uiWindowsUtilDestroy(HWND hwnd); _UI_EXTERN void uiWindowsUtilSetParent(HWND hwnd, uiControl *parent); _UI_EXTERN void uiWindowsUtilResize(HWND hwnd, intmax_t x, intmax_t y, intmax_t width, intmax_t height, uiSizing *d); @@ -19,6 +21,9 @@ _UI_EXTERN void uiWindowsUtilDisable(HWND hwnd); _UI_EXTERN uintptr_t uiWindowsUtilStartZOrder(HWND hwnd); _UI_EXTERN uintptr_t uiWindowsUtilSetZOrder(HWND hwnd, uintptr_t insertAfter); _UI_EXTERN int uiWindowsUtilHasTabStops(HWND hwnd); + +// This creates a uiControl with most uiControl methods filled out for controls that only require a single HWND. +// You must provide Handle() (which returns that HWND) and PreferredSize() yourself. _UI_EXTERN uiControl *uiWindowsNewSingleHWNDControl(uintmax_t type); // This contains the Windows-specific parts of the uiSizing structure. @@ -46,4 +51,16 @@ _UI_EXTERN intmax_t uiWindowsWindowTextWidth(HWND hwnd); _UI_EXTERN char *uiWindowsUtilText(HWND); _UI_EXTERN void uiWindowsUtilSetText(HWND, const char *); +// These provide event handling. +// For WM_COMMAND, the WORD parameter is the notification code. +// For WM_HSCROLL, the WORD parameter is the scroll operation. +extern void uiWindowsRegisterWM_COMMANDHandler(HWND, BOOL (*)(uiControl *, HWND, WORD, LRESULT *), uiControl *); +extern void uiWindowsRegisterWM_NOTIFYHandler(HWND, BOOL (*)(uiControl *, HWND, NMHDR *, LRESULT *), uiControl *); +extern void uiWindowsRegisterWM_HSCROLLHandler(HWND, BOOL (*)(uiControl *, HWND, WORD, LRESULT *), uiControl *); +extern void uiWindowsUnregisterWM_COMMANDHandler(HWND); +extern void uiWindowsUnregisterWM_NOTIFYHandler(HWND); +extern void uiWindowsUnregisterWM_HSCROLLHandler(HWND); +extern void uiWindowsRegisterReceiveWM_WININICHANGE(HWND); +extern void uiWindowsUnregisterReceiveWM_WININICHANGE(HWND); + #endif diff --git a/redo/windows/uipriv_windows.h b/redo/windows/uipriv_windows.h index b04797fc..541347eb 100644 --- a/redo/windows/uipriv_windows.h +++ b/redo/windows/uipriv_windows.h @@ -93,18 +93,9 @@ extern void tabEnterTabNavigation(HWND); extern void tabLeaveTabNavigation(HWND); // events.c -// TODO split the uiWindows ones to ui_windows.h -extern void uiWindowsRegisterWM_COMMANDHandler(HWND, BOOL (*)(uiControl *, HWND, WORD, LRESULT *), uiControl *); -extern void uiWindowsRegisterWM_NOTIFYHandler(HWND, BOOL (*)(uiControl *, HWND, NMHDR *, LRESULT *), uiControl *); -extern void uiWindowsRegisterWM_HSCROLLHandler(HWND, BOOL (*)(uiControl *, HWND, WORD, LRESULT *), uiControl *); -extern void uiWindowsUnregisterWM_COMMANDHandler(HWND); -extern void uiWindowsUnregisterWM_NOTIFYHandler(HWND); -extern void uiWindowsUnregisterWM_HSCROLLHandler(HWND); extern BOOL runWM_COMMAND(WPARAM, LPARAM, LRESULT *); extern BOOL runWM_NOTIFY(WPARAM, LPARAM, LRESULT *); extern BOOL runWM_HSCROLL(WPARAM, LPARAM, LRESULT *); -extern void uiWindowsRegisterReceiveWM_WININICHANGE(HWND); -extern void uiWindowsUnregisterReceiveWM_WININICHANGE(HWND); extern void issueWM_WININICHANGE(WPARAM, LPARAM); // dialoghelper.c