2015-04-24 13:09:48 -05:00
// 7 april 2015
/*
This file assumes that you have included < windows . h > and " ui.h " beforehand . It provides API - specific functions for interfacing with foreign controls in Windows .
*/
# ifndef __UI_UI_WINDOWS_H__
# define __UI_UI_WINDOWS_H__
2015-05-02 19:51:00 -05:00
// uiWindowsMakeControl() initializes the given uiControl with the given Windows API control inside.
2015-04-24 13:09:48 -05:00
// You will need to provide the preferredSize() method yourself.
2015-05-02 19:51:00 -05:00
typedef struct uiWindowsMakeControlParams uiWindowsMakeControlParams ;
struct uiWindowsMakeControlParams {
2015-04-24 13:09:48 -05:00
// These match the CreateWindowExW() function.
DWORD dwExStyle ;
LPCWSTR lpClassName ;
LPCWSTR lpWindowName ;
DWORD dwStyle ; // WS_CHILD and WS_VISIBLE are automatically applied.
HINSTANCE hInstance ;
// Set this to non-FALSE to use the standard control font used by other ui controls.
BOOL useStandardControlFont ;
// These are called when the control sends a WM_COMMAND or WM_NOTIFY (respectively) to its parent.
// ui redirects the message back and calls these functions.
// Store the result in *lResult and return any non-FALSE value (such as TRUE) to return the given result; return FALSE to pass the notification up to your window procedure.
// Note that these are only issued if they come from the uiControl itself; notifications from children of the uiControl (such as a header control) will be received normally.
BOOL ( * onWM_COMMAND ) ( uiControl * c , WORD code , LRESULT * lResult ) ;
BOOL ( * onWM_NOTIFY ) ( uiControl * c , NMHDR * nm , LRESULT * lResult ) ;
// This is called when the widget is ready to be destroyed.
void ( * onDestroy ) ( void * data ) ;
void * onDestroyData ;
} ;
2015-05-07 17:13:47 -05:00
_UI_EXTERN void uiWindowsMakeControl ( uiControl * c , uiWindowsMakeControlParams * p ) ;
2015-04-24 13:09:48 -05:00
// This contains the Windows-specific parts of the uiSizing structure.
2015-05-07 13:22:31 -05:00
// BaseX and BaseY are the dialog base units.
// InternalLeading is the standard control font's internal leading; labels in uiForms use this for correct Y positioning.
2015-04-24 13:09:48 -05:00
struct uiSizingSys {
2015-05-07 13:22:31 -05:00
int BaseX ;
int BaseY ;
LONG InternalLeading ;
2015-05-07 13:20:31 -05:00
// This is the window handle to pass to the hWndInsertAfter parameter of SetWindowPos().
// You should set this to your own window handle when done.
// Controls made with uiWindowsMakeControl() do this for you; you only need to do this if you are implementing uiControlResize() yourself.
HWND InsertAfter ;
2015-04-24 13:09:48 -05:00
} ;
2015-05-05 14:19:55 -05:00
// Use these in your preferredSize() implementation with baseX and baseY.
2015-05-07 11:58:33 -05:00
# define uiWindowsDlgUnitsToX(dlg, baseX) MulDiv((dlg), baseX, 4)
# define uiWindowsDlgUnitsToY(dlg, baseY) MulDiv((dlg), baseY, 8)
2015-04-24 13:09:48 -05:00
// and use this if you need the text of the window width
2015-05-07 17:13:47 -05:00
_UI_EXTERN intmax_t uiWindowsWindowTextWidth ( HWND hwnd ) ;
2015-04-24 13:09:48 -05:00
// these functions get and set the window text for such a uiControl
// the value returned should be freed with uiFreeText()
2015-05-07 17:13:47 -05:00
_UI_EXTERN char * uiWindowsControlText ( uiControl * ) ;
_UI_EXTERN void uiWindowsControlSetText ( uiControl * , const char * ) ;
2015-04-24 13:09:48 -05:00
2015-05-04 08:51:57 -05:00
struct uiControlSysFuncParams {
int Func ;
2015-05-06 17:05:07 -05:00
BOOL HasTabStops ;
2015-05-04 08:51:57 -05:00
} ;
enum {
// These should enable and disable the uiControl while preserving the user enable/disable setting.
// These are needed because while disabling a parent window does cause children to stop receiving events, they are not shown as disabled, which is not what we want.
uiWindowsSysFuncContainerEnable ,
uiWindowsSysFuncContainerDisable ,
2015-05-06 17:05:07 -05:00
// This is interpreted by controls that are tab stops; the control should set HasTabStops to TRUE if so, and *LEAVE IT ALONE* if not.
// You only need this if implementing your own uiControl.
2015-05-06 17:37:21 -05:00
// Controls created with uiWindowsMakeControl() check for the window being enabled and the presence of WS_TABSTOP.
2015-05-06 17:05:07 -05:00
// The name is "has tab stops" because it is used by uiTabs to say "does the current tab page have tab stops?".
uiWindowsSysFuncHasTabStops ,
2015-05-04 08:51:57 -05:00
} ;
2015-04-24 13:09:48 -05:00
# endif