2015-05-14 08:43:25 -05:00
|
|
|
// 6 january 2015
|
2016-04-20 19:20:10 -05:00
|
|
|
#include "winapi.hpp"
|
2015-08-31 16:50:23 -05:00
|
|
|
#include "../ui.h"
|
2015-05-14 08:43:25 -05:00
|
|
|
#include "../ui_windows.h"
|
2016-04-18 16:14:33 -05:00
|
|
|
#undef this // TODO
|
2015-10-16 17:31:14 -05:00
|
|
|
#include "../common/uipriv.h"
|
2016-04-20 19:20:10 -05:00
|
|
|
#include "resources.hpp"
|
|
|
|
#include "compilerver.hpp"
|
2015-12-22 15:00:51 -06:00
|
|
|
|
2015-05-14 08:43:25 -05:00
|
|
|
// ui internal window messages
|
|
|
|
enum {
|
|
|
|
// redirected WM_COMMAND and WM_NOTIFY
|
|
|
|
msgCOMMAND = WM_APP + 0x40, // start offset just to be safe
|
|
|
|
msgNOTIFY,
|
2015-05-19 22:16:46 -05:00
|
|
|
msgHSCROLL,
|
2015-05-14 08:43:25 -05:00
|
|
|
msgConsoleEndSession,
|
2015-12-04 22:42:03 -06:00
|
|
|
msgQueued,
|
2016-04-17 10:53:24 -05:00
|
|
|
msgD2DScratchPaint,
|
2015-05-14 08:43:25 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
// init.c
|
|
|
|
extern HINSTANCE hInstance;
|
|
|
|
extern int nCmdShow;
|
|
|
|
extern HFONT hMessageFont;
|
|
|
|
extern HBRUSH hollowBrush;
|
|
|
|
|
|
|
|
// util.c
|
|
|
|
extern int windowClassOf(HWND, ...);
|
|
|
|
extern void mapWindowRect(HWND, HWND, RECT *);
|
|
|
|
extern DWORD getStyle(HWND);
|
|
|
|
extern void setStyle(HWND, DWORD);
|
|
|
|
extern DWORD getExStyle(HWND);
|
|
|
|
extern void setExStyle(HWND, DWORD);
|
2015-09-02 15:02:06 -05:00
|
|
|
extern void clientSizeToWindowSize(HWND, intmax_t *, intmax_t *, BOOL);
|
2015-05-14 08:43:25 -05:00
|
|
|
|
|
|
|
// text.c
|
|
|
|
extern WCHAR *toUTF16(const char *);
|
|
|
|
extern char *toUTF8(const WCHAR *);
|
|
|
|
extern WCHAR *windowText(HWND);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-05-14 09:28:50 -05:00
|
|
|
|
|
|
|
/////////////////////////////////
|
|
|
|
|
|
|
|
// resize.c
|
|
|
|
extern void initResizes(void);
|
|
|
|
extern void uninitResizes(void);
|
|
|
|
extern void doResizes(void);
|
2015-05-30 02:40:14 -05:00
|
|
|
extern void setWindowInsertAfter(HWND, HWND);
|
2015-05-14 10:19:52 -05:00
|
|
|
|
|
|
|
// utilwindow.c
|
2015-05-15 15:19:21 -05:00
|
|
|
extern HWND utilWindow;
|
2015-05-14 10:19:52 -05:00
|
|
|
extern const char *initUtilWindow(HICON, HCURSOR);
|
|
|
|
extern void uninitUtilWindow(void);
|
2015-05-14 11:49:02 -05:00
|
|
|
|
|
|
|
// parent.c
|
2015-05-24 13:50:25 -05:00
|
|
|
extern void paintContainerBackground(HWND, HDC, RECT *);
|
2015-05-14 11:49:02 -05:00
|
|
|
extern BOOL handleParentMessages(HWND, UINT, WPARAM, LPARAM, LRESULT *);
|
2015-05-15 15:19:21 -05:00
|
|
|
|
|
|
|
// debug.c
|
|
|
|
extern HRESULT logLastError(const char *);
|
|
|
|
extern HRESULT logHRESULT(const char *, HRESULT);
|
|
|
|
extern HRESULT logMemoryExhausted(const char *);
|
|
|
|
|
|
|
|
// window.c
|
|
|
|
extern ATOM registerWindowClass(HICON, HCURSOR);
|
|
|
|
extern void unregisterWindowClass(void);
|
2015-09-02 15:26:54 -05:00
|
|
|
extern void ensureMinimumWindowSize(uiWindow *);
|
2015-05-15 15:19:21 -05:00
|
|
|
|
|
|
|
// container.c
|
2015-05-16 00:55:34 -05:00
|
|
|
#define containerClass L"libui_uiContainerClass"
|
2015-05-16 00:45:20 -05:00
|
|
|
extern ATOM initContainer(HICON, HCURSOR);
|
2015-05-15 15:19:21 -05:00
|
|
|
extern void uninitContainer(void);
|
2015-08-31 14:14:02 -05:00
|
|
|
extern HWND newContainer(void);
|
2015-05-15 15:19:21 -05:00
|
|
|
|
|
|
|
// menu.c
|
|
|
|
extern HMENU makeMenubar(void);
|
|
|
|
extern const uiMenuItem *menuIDToItem(UINT_PTR);
|
|
|
|
extern void runMenuEvent(WORD, uiWindow *);
|
|
|
|
extern void freeMenubar(HMENU);
|
|
|
|
extern void uninitMenus(void);
|
|
|
|
|
|
|
|
// alloc.c
|
2016-04-20 19:20:10 -05:00
|
|
|
extern void initAlloc(void);
|
2015-05-15 15:19:21 -05:00
|
|
|
extern void uninitAlloc(void);
|
2015-05-15 17:54:13 -05:00
|
|
|
|
2015-05-20 21:46:50 -05:00
|
|
|
// events.c
|
|
|
|
extern BOOL runWM_COMMAND(WPARAM, LPARAM, LRESULT *);
|
2015-05-21 10:29:25 -05:00
|
|
|
extern BOOL runWM_NOTIFY(WPARAM, LPARAM, LRESULT *);
|
|
|
|
extern BOOL runWM_HSCROLL(WPARAM, LPARAM, LRESULT *);
|
2015-06-03 23:26:13 -05:00
|
|
|
extern void issueWM_WININICHANGE(WPARAM, LPARAM);
|
2015-05-22 16:41:36 -05:00
|
|
|
|
2015-08-31 14:14:02 -05:00
|
|
|
// child.c
|
|
|
|
extern struct child *newChild(uiControl *child, uiControl *parent, HWND parentHWND);
|
|
|
|
extern struct child *newChildWithTabPage(uiControl *child, uiControl *parent, HWND parentHWND);
|
|
|
|
extern void childRemove(struct child *c);
|
|
|
|
extern void childDestroy(struct child *c);
|
|
|
|
extern HWND childHWND(struct child *c);
|
|
|
|
extern void childMinimumSize(struct child *c, uiWindowsSizing *d, intmax_t *width, intmax_t *height);
|
|
|
|
extern void childRelayout(struct child *c, intmax_t x, intmax_t y, intmax_t width, intmax_t height);
|
2015-09-01 06:21:18 -05:00
|
|
|
extern void childQueueRelayout(struct child *c);
|
2015-09-01 15:44:09 -05:00
|
|
|
extern int childVisible(struct child *c);
|
2015-08-31 14:14:02 -05:00
|
|
|
extern void childUpdateState(struct child *c);
|
2015-09-02 08:36:53 -05:00
|
|
|
extern void childAssignControlIDZOrder(struct child *c, LONG_PTR *controlID, HWND *insertAfter);
|
2015-09-02 08:18:49 -05:00
|
|
|
extern void childSetSoleControlID(struct child *c);
|
2015-08-31 14:14:02 -05:00
|
|
|
extern HWND childTabPage(struct child *c);
|
|
|
|
extern int childMargined(struct child *c);
|
2015-08-31 16:50:23 -05:00
|
|
|
extern void childSetMargined(struct child *c, int margined);
|
2015-08-31 14:14:02 -05:00
|
|
|
extern int childFlag(struct child *c);
|
|
|
|
extern void childSetFlag(struct child *c, int flag);
|
2015-08-31 16:05:50 -05:00
|
|
|
extern intmax_t childIntmax(struct child *c, int n);
|
|
|
|
extern void childSetIntmax(struct child *c, int n, intmax_t to);
|
2015-08-31 16:50:23 -05:00
|
|
|
|
|
|
|
// tabpage.c
|
|
|
|
extern void tabPageMargins(HWND, intmax_t *, intmax_t *, intmax_t *, intmax_t *);
|
|
|
|
extern HWND newTabPage(void);
|
2015-10-09 10:17:58 -05:00
|
|
|
|
|
|
|
// area.c
|
|
|
|
#define areaClass L"libui_uiAreaClass"
|
|
|
|
extern ATOM registerAreaClass(HICON, HCURSOR);
|
2015-11-27 20:45:30 -06:00
|
|
|
extern void unregisterArea(void);
|
2015-10-09 10:17:58 -05:00
|
|
|
|
2015-12-18 11:00:46 -06:00
|
|
|
// areaevents.c
|
|
|
|
// TODO merge into registerAreaClass()?
|
|
|
|
extern int registerAreaFilter(void);
|
|
|
|
|
2015-10-09 10:17:58 -05:00
|
|
|
// draw.c
|
|
|
|
extern HRESULT initDraw(void);
|
|
|
|
extern void uninitDraw(void);
|
|
|
|
extern ID2D1HwndRenderTarget *makeHWNDRenderTarget(HWND hwnd);
|
|
|
|
extern uiDrawContext *newContext(ID2D1RenderTarget *);
|
|
|
|
extern void freeContext(uiDrawContext *);
|
2016-04-19 17:45:16 -05:00
|
|
|
extern ID2D1Brush *createSolidColorBrushInternal(ID2D1RenderTarget *rt, double r, double g, double b, double a);
|
2015-12-22 15:00:51 -06:00
|
|
|
|
2016-04-14 18:57:58 -05:00
|
|
|
// dwrite.cpp
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern IDWriteFactory *dwfactory;
|
|
|
|
#endif
|
2015-12-22 15:00:51 -06:00
|
|
|
extern HRESULT initDrawText(void);
|
|
|
|
extern void uninitDrawText(void);
|
2016-04-14 18:57:58 -05:00
|
|
|
#ifdef __cplusplus
|
|
|
|
struct fontCollection {
|
|
|
|
IDWriteFontCollection *fonts;
|
|
|
|
WCHAR userLocale[LOCALE_NAME_MAX_LENGTH];
|
|
|
|
int userLocaleSuccess;
|
|
|
|
};
|
|
|
|
extern fontCollection *loadFontCollection(void);
|
|
|
|
extern WCHAR *fontCollectionFamilyName(fontCollection *fc, IDWriteFontFamily *family);
|
|
|
|
extern void fontCollectionFree(fontCollection *fc);
|
2016-04-15 09:14:23 -05:00
|
|
|
extern WCHAR *fontCollectionCorrectString(fontCollection *fc, IDWriteLocalizedStrings *names);
|
2016-04-14 18:57:58 -05:00
|
|
|
#endif
|
|
|
|
|
|
|
|
// drawtext.cpp
|
2016-04-17 23:41:17 -05:00
|
|
|
#ifdef __cplusplus
|
2016-04-20 13:17:55 -05:00
|
|
|
extern uiDrawTextFont *mkTextFont(IDWriteFont *df, BOOL addRef, WCHAR *family, BOOL copyFamily, double size);
|
2016-04-17 23:41:17 -05:00
|
|
|
struct dwriteAttr {
|
|
|
|
uiDrawTextWeight weight;
|
|
|
|
uiDrawTextItalic italic;
|
|
|
|
uiDrawTextStretch stretch;
|
|
|
|
DWRITE_FONT_WEIGHT dweight;
|
|
|
|
DWRITE_FONT_STYLE ditalic;
|
|
|
|
DWRITE_FONT_STRETCH dstretch;
|
|
|
|
};
|
|
|
|
extern void attrToDWriteAttr(struct dwriteAttr *attr);
|
|
|
|
extern void dwriteAttrToAttr(struct dwriteAttr *attr);
|
|
|
|
#endif
|
2016-01-09 00:07:48 -06:00
|
|
|
extern void doDrawText(ID2D1RenderTarget *rt, ID2D1Brush *black, double x, double y, uiDrawTextLayout *layout);
|
2015-12-22 15:00:51 -06:00
|
|
|
|
2016-04-14 20:35:50 -05:00
|
|
|
// fontdialog.cpp
|
2016-04-18 14:31:52 -05:00
|
|
|
#ifdef __cplusplus
|
2016-04-18 12:32:48 -05:00
|
|
|
struct fontDialogParams {
|
2016-04-18 14:31:52 -05:00
|
|
|
IDWriteFont *font;
|
|
|
|
double size;
|
|
|
|
WCHAR *familyName;
|
|
|
|
WCHAR *styleName;
|
2016-04-18 12:32:48 -05:00
|
|
|
};
|
|
|
|
extern BOOL showFontDialog(HWND parent, struct fontDialogParams *params);
|
|
|
|
extern void loadInitialFontDialogParams(struct fontDialogParams *params);
|
2016-04-18 14:31:52 -05:00
|
|
|
extern void destroyFontDialogParams(struct fontDialogParams *params);
|
2016-04-18 16:14:33 -05:00
|
|
|
extern WCHAR *fontDialogParamsToString(struct fontDialogParams *params);
|
2016-04-18 14:31:52 -05:00
|
|
|
#endif
|
2016-04-14 20:35:50 -05:00
|
|
|
|
2016-04-17 10:53:24 -05:00
|
|
|
// d2dscratch.c
|
|
|
|
extern ATOM registerD2DScratchClass(HICON, HCURSOR);
|
|
|
|
extern void unregisterD2DScratchClass(void);
|
|
|
|
extern HWND newD2DScratch(HWND parent, RECT *rect, HMENU controlID, SUBCLASSPROC subclass, DWORD_PTR subclassData);
|