2015-04-06 23:56:06 -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-04-16 00:52:31 -05:00
// uiWindowsNewControl() initializes the given uiControl with the given Windows API control inside.
2015-04-09 16:24:26 -05:00
// You will need to provide the preferredSize() method yourself.
2015-04-06 23:56:06 -05:00
typedef struct uiWindowsNewControlParams uiWindowsNewControlParams ;
struct uiWindowsNewControlParams {
// These match the CreateWindowExW() function.
DWORD dwExStyle ;
LPCWSTR lpClassName ;
2015-04-08 19:01:33 -05:00
LPCWSTR lpWindowName ;
2015-04-06 23:56:06 -05:00
DWORD dwStyle ; // WS_CHILD and WS_VISIBLE are automatically applied.
HINSTANCE hInstance ;
2015-04-10 16:53:59 -05:00
// Set this to non-FALSE to use the standard control font used by other ui controls.
BOOL useStandardControlFont ;
2015-04-06 23:56:06 -05:00
// 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.
2015-04-07 01:46:27 -05:00
// 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.
2015-04-06 23:56:06 -05:00
// 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.
2015-04-09 17:54:14 -05:00
BOOL ( * onWM_COMMAND ) ( uiControl * c , WORD code , LRESULT * lResult ) ;
2015-04-17 12:18:26 -05:00
// TODO set idFrom to 0?
2015-04-09 18:07:41 -05:00
BOOL ( * onWM_NOTIFY ) ( uiControl * c , NMHDR * nm , LRESULT * lResult ) ;
2015-04-18 17:02:16 -05:00
// This is called when the widget is ready to be destroyed.
void ( * onDestroy ) ( void * data ) ;
void * onDestroyData ;
2015-04-06 23:56:06 -05:00
} ;
2015-04-16 00:52:31 -05:00
void uiWindowsNewControl ( uiControl * c , uiWindowsNewControlParams * p ) ;
2015-04-06 23:56:06 -05:00
2015-04-09 16:24:26 -05:00
// This contains the Windows-specific parts of the uiSizing structure.
// 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.
struct uiSizingSys {
int baseX ;
int baseY ;
LONG internalLeading ;
} ;
// Use these in your preferredSize() implementation with baseX and baseY.
2015-04-09 17:45:58 -05:00
# define uiDlgUnitsToX(dlg, baseX) MulDiv((dlg), baseX, 4)
# define uiDlgUnitsToY(dlg, baseY) MulDiv((dlg), baseY, 8)
2015-04-07 02:39:47 -05:00
2015-04-07 18:32:16 -05:00
// and use this if you need the text of the window width
extern intmax_t uiWindowsWindowTextWidth ( HWND hwnd ) ;
2015-04-09 10:12:01 -05:00
// these functions get and set the window text for such a uiControl
// the value returned should be freed with uiFreeText()
extern char * uiWindowsControlText ( uiControl * ) ;
extern void uiWindowsControlSetText ( uiControl * , const char * ) ;
2015-04-06 23:56:06 -05:00
# endif