2016-04-21 11:55:09 -05:00
// 21 april 2016
2016-04-23 14:46:39 -05:00
# include "winapi.hpp"
# include "../ui.h"
# include "../ui_windows.h"
# include "../common/uipriv.h"
# include "resources.hpp"
# include "compilerver.hpp"
// ui internal window messages
enum {
// redirected WM_COMMAND and WM_NOTIFY
msgCOMMAND = WM_APP + 0x40 , // start offset just to be safe
msgNOTIFY ,
msgHSCROLL ,
msgQueued ,
msgD2DScratchPaint ,
2016-05-17 13:44:57 -05:00
msgD2DScratchLButtonDown ,
2016-04-23 14:46:39 -05:00
} ;
2016-04-21 11:55:09 -05:00
2016-04-22 12:31:33 -05:00
// alloc.cpp
extern void initAlloc ( void ) ;
extern void uninitAlloc ( void ) ;
2016-04-21 11:55:09 -05:00
// events.cpp
extern BOOL runWM_COMMAND ( WPARAM wParam , LPARAM lParam , LRESULT * lResult ) ;
extern BOOL runWM_NOTIFY ( WPARAM wParam , LPARAM lParam , LRESULT * lResult ) ;
extern BOOL runWM_HSCROLL ( WPARAM wParam , LPARAM lParam , LRESULT * lResult ) ;
extern void issueWM_WININICHANGE ( WPARAM wParam , LPARAM lParam ) ;
2016-04-21 17:03:52 -05:00
// utf16.cpp
2016-04-21 22:29:44 -05:00
# define emptyUTF16() ((WCHAR *) uiAlloc(1 * sizeof (WCHAR), "WCHAR[]"))
# define emptyUTF8() ((char *) uiAlloc(1 * sizeof (char), "char[]"))
2016-04-21 17:03:52 -05:00
extern WCHAR * toUTF16 ( const char * str ) ;
extern char * toUTF8 ( const WCHAR * wstr ) ;
2016-04-22 12:01:55 -05:00
extern WCHAR * utf16dup ( const WCHAR * orig ) ;
2016-04-21 17:03:52 -05:00
extern WCHAR * strf ( const WCHAR * format , . . . ) ;
extern WCHAR * vstrf ( const WCHAR * format , va_list ap ) ;
2016-04-21 17:10:30 -05:00
extern char * LFtoCRLF ( const char * lfonly ) ;
2016-05-22 12:42:37 -05:00
extern void CRLFtoLF ( char * s ) ;
2016-05-17 11:35:44 -05:00
extern WCHAR * ftoutf16 ( double d ) ;
2016-06-13 20:47:04 -05:00
extern WCHAR * itoutf16 ( int i ) ;
2016-04-21 17:03:52 -05:00
// debug.cpp
2016-04-23 16:31:59 -05:00
// see http://stackoverflow.com/questions/14421656/is-there-widely-available-wide-character-variant-of-file
2016-04-23 21:15:33 -05:00
// we turn __LINE__ into a string because PRIiMAX can't be converted to a wide string in MSVC (it seems to be defined as "ll" "i" according to the compiler errors)
2016-04-23 19:26:37 -05:00
// also note the use of __FUNCTION__ here; __func__ doesn't seem to work for some reason
# define _ws2(m) L ## m
# define _ws(m) _ws2(m)
2016-04-23 21:15:33 -05:00
# define _ws2n(m) L ## #m
# define _wsn(m) _ws2n(m)
# define debugargs const WCHAR *file, const WCHAR *line, const WCHAR *func
2016-04-23 16:31:59 -05:00
extern HRESULT _logLastError ( debugargs , const WCHAR * s ) ;
2016-06-01 20:45:39 -05:00
# ifdef _MSC_VER
2016-04-23 21:15:33 -05:00
# define logLastError(s) _logLastError(_ws(__FILE__), _wsn(__LINE__), _ws(__FUNCTION__), s)
2016-06-01 20:45:39 -05:00
# else
# define logLastError(s) _logLastError(_ws(__FILE__), _wsn(__LINE__), L"TODO none of the function name macros are macros in MinGW", s)
# endif
2016-04-21 17:03:52 -05:00
extern HRESULT _logHRESULT ( debugargs , const WCHAR * s , HRESULT hr ) ;
2016-06-01 20:45:39 -05:00
# ifdef _MSC_VER
2016-04-23 21:15:33 -05:00
# define logHRESULT(s, hr) _logHRESULT(_ws(__FILE__), _wsn(__LINE__), _ws(__FUNCTION__), s, hr)
2016-06-01 20:45:39 -05:00
# else
# define logHRESULT(s, hr) _logHRESULT(_ws(__FILE__), _wsn(__LINE__), L"TODO none of the function name macros are macros in MinGW", s, hr)
# endif
2016-04-21 22:05:10 -05:00
// winutil.cpp
extern int windowClassOf ( HWND hwnd , . . . ) ;
extern void mapWindowRect ( HWND from , HWND to , RECT * r ) ;
extern DWORD getStyle ( HWND hwnd ) ;
extern void setStyle ( HWND hwnd , DWORD style ) ;
extern DWORD getExStyle ( HWND hwnd ) ;
extern void setExStyle ( HWND hwnd , DWORD exstyle ) ;
2016-06-13 20:47:04 -05:00
extern void clientSizeToWindowSize ( HWND hwnd , int * width , int * height , BOOL hasMenubar ) ;
2016-04-21 22:05:10 -05:00
extern HWND parentOf ( HWND child ) ;
extern HWND parentToplevel ( HWND child ) ;
2016-04-22 18:51:33 -05:00
extern void setWindowInsertAfter ( HWND hwnd , HWND insertAfter ) ;
2016-05-16 18:28:30 -05:00
extern HWND getDlgItem ( HWND hwnd , int id ) ;
2016-05-17 11:41:41 -05:00
extern void invalidateRect ( HWND hwnd , RECT * r , BOOL erase ) ;
2016-04-21 22:29:44 -05:00
// text.cpp
extern WCHAR * windowTextAndLen ( HWND hwnd , LRESULT * len ) ;
extern WCHAR * windowText ( HWND hwnd ) ;
extern void setWindowText ( HWND hwnd , WCHAR * wtext ) ;
2016-04-22 12:31:33 -05:00
// init.cpp
extern HINSTANCE hInstance ;
extern int nCmdShow ;
extern HFONT hMessageFont ;
extern HBRUSH hollowBrush ;
extern uiInitOptions options ;
2016-04-22 12:52:02 -05:00
// utilwin.cpp
extern HWND utilWindow ;
extern const char * initUtilWindow ( HICON hDefaultIcon , HCURSOR hDefaultCursor ) ;
extern void uninitUtilWindow ( void ) ;
2016-04-22 13:36:21 -05:00
// main.cpp
2016-04-23 21:29:54 -05:00
extern int registerMessageFilter ( void ) ;
2016-04-22 13:36:21 -05:00
extern void unregisterMessageFilter ( void ) ;
2016-04-22 17:11:20 -05:00
// parent.cpp
extern void paintContainerBackground ( HWND hwnd , HDC dc , RECT * paintRect ) ;
extern BOOL handleParentMessages ( HWND hwnd , UINT uMsg , WPARAM wParam , LPARAM lParam , LRESULT * lResult ) ;
2016-04-22 18:51:33 -05:00
2016-04-23 10:50:47 -05:00
// d2dscratch.cpp
extern ATOM registerD2DScratchClass ( HICON hDefaultIcon , HCURSOR hDefaultCursor ) ;
extern void unregisterD2DScratchClass ( void ) ;
extern HWND newD2DScratch ( HWND parent , RECT * rect , HMENU controlID , SUBCLASSPROC subclass , DWORD_PTR subclassData ) ;
2016-04-23 14:46:39 -05:00
// area.cpp
# define areaClass L"libui_uiAreaClass"
extern ATOM registerAreaClass ( HICON , HCURSOR ) ;
extern void unregisterArea ( void ) ;
// areaevents.cpp
extern BOOL areaFilter ( MSG * ) ;
// window.cpp
extern ATOM registerWindowClass ( HICON , HCURSOR ) ;
extern void unregisterWindowClass ( void ) ;
extern void ensureMinimumWindowSize ( uiWindow * ) ;
2016-05-15 18:22:15 -05:00
extern void disableAllWindowsExcept ( uiWindow * which ) ;
extern void enableAllWindowsExcept ( uiWindow * which ) ;
2016-04-22 20:36:19 -05:00
2016-04-23 14:46:39 -05:00
// container.cpp
# define containerClass L"libui_uiContainerClass"
extern ATOM initContainer ( HICON , HCURSOR ) ;
extern void uninitContainer ( void ) ;
2016-04-27 11:41:30 -05:00
// tabpage.cpp
struct tabPage {
HWND hwnd ;
uiControl * child ;
BOOL margined ;
} ;
extern struct tabPage * newTabPage ( uiControl * child ) ;
extern void tabPageDestroy ( struct tabPage * tp ) ;
2016-06-13 20:47:04 -05:00
extern void tabPageMinimumSize ( struct tabPage * tp , int * width , int * height ) ;
2016-04-27 11:41:30 -05:00
2016-05-16 18:28:30 -05:00
// colordialog.cpp
struct colorDialogRGBA {
double r ;
double g ;
double b ;
double a ;
} ;
extern BOOL showColorDialog ( HWND parent , struct colorDialogRGBA * c ) ;
2016-05-22 12:09:13 -05:00
// sizing.cpp
extern void getSizing ( HWND hwnd , uiWindowsSizing * sizing , HFONT font ) ;
2016-06-05 15:07:40 -05:00
// TODO move into a dedicated file abibugs.cpp when we rewrite the drawing code
extern D2D1_SIZE_F realGetSize ( ID2D1RenderTarget * rt ) ;
2016-05-25 00:08:55 -05:00
2016-04-27 11:41:30 -05:00
2016-04-23 14:46:39 -05:00
// TODO
# include "_uipriv_migrate.hpp"
2016-05-22 14:59:23 -05:00
// draw.cpp
extern ID2D1DCRenderTarget * makeHDCRenderTarget ( HDC dc , RECT * r ) ;
2017-02-11 15:55:30 -06:00
// drawtext.cpp
extern void fontdescFromIDWriteFont ( IDWriteFont * font , uiDrawFontDescriptor * uidesc ) ;
2017-05-17 14:57:39 -05:00
// opentype.cpp
extern IDWriteTypography * otfToDirectWrite ( uiOpenTypeFeatures * otf ) ;