Merged the Windows uiArea back into the main library.
This commit is contained in:
parent
2780105b7b
commit
e4e72e55bb
|
@ -1,21 +0,0 @@
|
||||||
// 8 september 2015
|
|
||||||
#include "../windows/winapi.h"
|
|
||||||
#include <d2d1.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
#include "ui.h"
|
|
||||||
#include "uipriv.h"
|
|
||||||
#include "uipriv_windows.h"
|
|
||||||
|
|
||||||
extern HINSTANCE hInstance;
|
|
||||||
|
|
||||||
extern ATOM registerAreaClass(void);
|
|
||||||
extern void unregisterAreaClass(void);
|
|
||||||
extern HWND makeArea(DWORD exstyle, DWORD style, int x, int y, int cx, int cy, HWND parent, uiAreaHandler *ah);
|
|
||||||
|
|
||||||
extern HRESULT logLastError(const char *);
|
|
||||||
extern HRESULT logHRESULT(const char *, HRESULT);
|
|
||||||
extern HRESULT logMemoryExhausted(const char *);
|
|
||||||
|
|
||||||
extern uiDrawContext *newContext(ID2D1RenderTarget *);
|
|
||||||
|
|
||||||
extern void areaUpdateScroll(HWND);
|
|
|
@ -1,6 +0,0 @@
|
||||||
// 16 september 2015
|
|
||||||
|
|
||||||
// draw.c
|
|
||||||
extern HRESULT initDraw(void);
|
|
||||||
extern void uninitDraw(void);
|
|
||||||
extern ID2D1HwndRenderTarget *makeHWNDRenderTarget(HWND hwnd);
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
osCFILES = \
|
osCFILES = \
|
||||||
windows/alloc.c \
|
windows/alloc.c \
|
||||||
|
windows/area.c \
|
||||||
windows/box.c \
|
windows/box.c \
|
||||||
windows/button.c \
|
windows/button.c \
|
||||||
windows/checkbox.c \
|
windows/checkbox.c \
|
||||||
|
@ -12,6 +13,7 @@ osCFILES = \
|
||||||
windows/datetimepicker.c \
|
windows/datetimepicker.c \
|
||||||
windows/debug.c \
|
windows/debug.c \
|
||||||
windows/dialoghelper.c \
|
windows/dialoghelper.c \
|
||||||
|
windows/draw.c \
|
||||||
windows/entry.c \
|
windows/entry.c \
|
||||||
windows/events.c \
|
windows/events.c \
|
||||||
windows/group.c \
|
windows/group.c \
|
||||||
|
@ -49,7 +51,7 @@ osCFLAGS = \
|
||||||
|
|
||||||
osLDFLAGS = \
|
osLDFLAGS = \
|
||||||
-static-libgcc \
|
-static-libgcc \
|
||||||
-luser32 -lkernel32 -lgdi32 -lcomctl32 -luxtheme -lmsimg32 -lcomdlg32 -lole32 -loleaut32 -loleacc -luuid
|
-luser32 -lkernel32 -lgdi32 -lcomctl32 -luxtheme -lmsimg32 -lcomdlg32 -ld2d1 -lole32 -loleaut32 -loleacc -luuid
|
||||||
|
|
||||||
osLDWarnUndefinedFlags = -Wl,--no-undefined -Wl,--no-allow-shlib-undefined
|
osLDWarnUndefinedFlags = -Wl,--no-undefined -Wl,--no-allow-shlib-undefined
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
// 8 september 2015
|
// 8 september 2015
|
||||||
#include "area.h"
|
#include "uipriv_windows.h"
|
||||||
|
|
||||||
// TODOs
|
// TODOs
|
||||||
// - things look very wrong on initial draw
|
// - things look very wrong on initial draw
|
||||||
|
// - initial scrolling is not set properly
|
||||||
#define areaClass L"libui_uiAreaClass"
|
// - should background be inherited from parent control?
|
||||||
|
|
||||||
struct uiArea {
|
struct uiArea {
|
||||||
// uiWindowsControl c;
|
uiWindowsControl c;
|
||||||
HWND hwnd;
|
HWND hwnd;
|
||||||
uiAreaHandler *ah;
|
uiAreaHandler *ah;
|
||||||
intmax_t hscrollpos;
|
intmax_t hscrollpos;
|
||||||
|
@ -19,6 +19,11 @@ struct uiArea {
|
||||||
ID2D1HwndRenderTarget *rt;
|
ID2D1HwndRenderTarget *rt;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
uiWindowsDefineControl(
|
||||||
|
uiArea, // type name
|
||||||
|
uiAreaType // type function
|
||||||
|
)
|
||||||
|
|
||||||
static HRESULT doPaint(uiArea *a, ID2D1RenderTarget *rt, RECT *client, RECT *clip)
|
static HRESULT doPaint(uiArea *a, ID2D1RenderTarget *rt, RECT *client, RECT *clip)
|
||||||
{
|
{
|
||||||
uiAreaHandler *ah = a->ah;
|
uiAreaHandler *ah = a->ah;
|
||||||
|
@ -617,19 +622,20 @@ static LRESULT CALLBACK areaWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM
|
||||||
return DefWindowProc(hwnd, uMsg, wParam, lParam);
|
return DefWindowProc(hwnd, uMsg, wParam, lParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// control implementation
|
||||||
|
|
||||||
|
static void minimumSize(uiWindowsControl *c, uiWindowsSizing *d, intmax_t *width, intmax_t *height)
|
||||||
|
{
|
||||||
|
// TODO
|
||||||
|
*width = 0;
|
||||||
|
*height = 0;
|
||||||
|
}
|
||||||
|
|
||||||
// TODO affect visibility properly
|
// TODO affect visibility properly
|
||||||
BOOL processAreaMessage(MSG *msg)
|
void processAreaMessage(HWND active, MSG *msg)
|
||||||
{
|
{
|
||||||
LRESULT handled;
|
LRESULT handled;
|
||||||
|
|
||||||
// TODO get rid of this part
|
|
||||||
WCHAR classname[260 + 1];
|
|
||||||
GetClassNameW(msg->hwnd, classname, 260);
|
|
||||||
if (wcscmp(classname, areaClass) != 0) return FALSE;
|
|
||||||
HWND active;
|
|
||||||
active = GetActiveWindow();
|
|
||||||
if (active == NULL) return FALSE;
|
|
||||||
|
|
||||||
handled = 0;
|
handled = 0;
|
||||||
switch (msg->message) {
|
switch (msg->message) {
|
||||||
case WM_KEYDOWN:
|
case WM_KEYDOWN:
|
||||||
|
@ -642,17 +648,16 @@ BOOL processAreaMessage(MSG *msg)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (handled)
|
if (handled)
|
||||||
return TRUE;
|
return;
|
||||||
|
|
||||||
// don't call TranslateMessage(); we do our own keyboard handling
|
// don't call TranslateMessage(); we do our own keyboard handling
|
||||||
// TODO should we just return to the standard message loop?
|
// TODO should we just return to the standard message loop?
|
||||||
if (IsDialogMessage(active, msg) != 0)
|
if (IsDialogMessage(active, msg) != 0)
|
||||||
return TRUE;
|
return;
|
||||||
DispatchMessageW(msg);
|
DispatchMessageW(msg);
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ATOM registerAreaClass(void)
|
ATOM registerAreaClass(HICON hDefaultIcon, HCURSOR hDefaultCursor)
|
||||||
{
|
{
|
||||||
WNDCLASSW wc;
|
WNDCLASSW wc;
|
||||||
|
|
||||||
|
@ -660,8 +665,8 @@ ATOM registerAreaClass(void)
|
||||||
wc.lpszClassName = areaClass;
|
wc.lpszClassName = areaClass;
|
||||||
wc.lpfnWndProc = areaWndProc;
|
wc.lpfnWndProc = areaWndProc;
|
||||||
wc.hInstance = hInstance;
|
wc.hInstance = hInstance;
|
||||||
//TODO wc.hIcon = hDefaultIcon;
|
wc.hIcon = hDefaultIcon;
|
||||||
//TODO wc.hCursor = hDefaultCursor;
|
wc.hCursor = hDefaultCursor;
|
||||||
wc.hbrBackground = (HBRUSH) (COLOR_BTNFACE + 1);
|
wc.hbrBackground = (HBRUSH) (COLOR_BTNFACE + 1);
|
||||||
// don't specify CS_HREDRAW or CS_VREDRAW; that's decided by the uiAreaHandler in RedrawOnResize()
|
// don't specify CS_HREDRAW or CS_VREDRAW; that's decided by the uiAreaHandler in RedrawOnResize()
|
||||||
return RegisterClassW(&wc);
|
return RegisterClassW(&wc);
|
||||||
|
@ -673,35 +678,29 @@ void unregisterAreaClass(void)
|
||||||
logLastError("error unregistering uiArea window class in unregisterAreaClass()");
|
logLastError("error unregistering uiArea window class in unregisterAreaClass()");
|
||||||
}
|
}
|
||||||
|
|
||||||
HWND makeArea(DWORD exstyle, DWORD style, int x, int y, int cx, int cy, HWND parent, uiAreaHandler *ah)
|
void uiAreaUpdateScroll(uiArea *a)
|
||||||
{
|
{
|
||||||
uiArea *a;
|
|
||||||
|
|
||||||
// TODO
|
|
||||||
a = malloc(sizeof (uiArea));
|
|
||||||
a->rt = NULL;
|
|
||||||
|
|
||||||
a->ah = ah;
|
|
||||||
|
|
||||||
a->hwnd = CreateWindowExW(exstyle,
|
|
||||||
areaClass, L"",
|
|
||||||
style | WS_HSCROLL | WS_VSCROLL,
|
|
||||||
x, y, cx, cy,
|
|
||||||
parent, NULL, hInstance, a);
|
|
||||||
|
|
||||||
clickCounterReset(&(a->cc));
|
|
||||||
|
|
||||||
a->capturing = FALSE;
|
|
||||||
|
|
||||||
return a->hwnd;
|
|
||||||
}
|
|
||||||
|
|
||||||
void areaUpdateScroll(HWND area)
|
|
||||||
{
|
|
||||||
uiArea *a;
|
|
||||||
|
|
||||||
a = (uiArea *) GetWindowLongPtrW(area, GWLP_USERDATA);
|
|
||||||
// use a no-op scroll to simulate scrolling
|
// use a no-op scroll to simulate scrolling
|
||||||
hscrollby(a, 0);
|
hscrollby(a, 0);
|
||||||
vscrollby(a, 0);
|
vscrollby(a, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uiArea *uiNewArea(uiAreaHandler *ah)
|
||||||
|
{
|
||||||
|
uiArea *a;
|
||||||
|
|
||||||
|
a = (uiArea *) uiNewControl(uiAreaType());
|
||||||
|
|
||||||
|
a->ah = ah;
|
||||||
|
clickCounterReset(&(a->cc));
|
||||||
|
|
||||||
|
a->hwnd = uiWindowsEnsureCreateControlHWND(0,
|
||||||
|
areaClass, L"",
|
||||||
|
WS_HSCROLL | WS_VSCROLL,
|
||||||
|
hInstance, a,
|
||||||
|
FALSE);
|
||||||
|
|
||||||
|
uiWindowsFinishNewControl(a, uiArea);
|
||||||
|
|
||||||
|
return a;
|
||||||
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
// 7 september 2015
|
// 7 september 2015
|
||||||
#include "area.h"
|
#include "uipriv_windows.h"
|
||||||
|
|
||||||
static ID2D1Factory *d2dfactory = NULL;
|
static ID2D1Factory *d2dfactory = NULL;
|
||||||
|
|
|
@ -158,12 +158,21 @@ const char *uiInit(uiInitOptions *o)
|
||||||
// TODO initialize COM security
|
// TODO initialize COM security
|
||||||
// TODO (windows vista) turn off COM exception handling
|
// TODO (windows vista) turn off COM exception handling
|
||||||
|
|
||||||
|
hr = initDraw();
|
||||||
|
if (hr != S_OK)
|
||||||
|
return loadHRESULT("initializing Direct2D", hr);
|
||||||
|
|
||||||
|
if (registerAreaClass(hDefaultIcon, hDefaultCursor) == 0)
|
||||||
|
return loadLastError("registering uiArea window class");
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void uiUninit(void)
|
void uiUninit(void)
|
||||||
{
|
{
|
||||||
uninitMenus();
|
uninitMenus();
|
||||||
|
unregisterAreaClass();
|
||||||
|
uninitDraw();
|
||||||
CoUninitialize();
|
CoUninitialize();
|
||||||
uninitDialogHelper();
|
uninitDialogHelper();
|
||||||
if (DeleteObject(hollowBrush) == 0)
|
if (DeleteObject(hollowBrush) == 0)
|
||||||
|
|
|
@ -33,9 +33,9 @@ void uiMain(void)
|
||||||
// as for Tabs, we can't have both WS_TABSTOP and WS_EX_CONTROLPARENT set at the same time, so we hotswap the two styles to get the behavior we want
|
// as for Tabs, we can't have both WS_TABSTOP and WS_EX_CONTROLPARENT set at the same time, so we hotswap the two styles to get the behavior we want
|
||||||
focus = GetFocus();
|
focus = GetFocus();
|
||||||
if (focus != NULL) {
|
if (focus != NULL) {
|
||||||
switch (windowClassOf(focus, L"TODO Area not yet implemented", NULL)) {
|
switch (windowClassOf(focus, areaClass, NULL)) {
|
||||||
case 0: // uiArea
|
case 0: // uiArea
|
||||||
// msgloop_area(active, focus, &msg);
|
processAreaMessage(active, &msg);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// else fall through
|
// else fall through
|
||||||
|
|
|
@ -121,3 +121,16 @@ extern void childSetIntmax(struct child *c, int n, intmax_t to);
|
||||||
// tabpage.c
|
// tabpage.c
|
||||||
extern void tabPageMargins(HWND, intmax_t *, intmax_t *, intmax_t *, intmax_t *);
|
extern void tabPageMargins(HWND, intmax_t *, intmax_t *, intmax_t *, intmax_t *);
|
||||||
extern HWND newTabPage(void);
|
extern HWND newTabPage(void);
|
||||||
|
|
||||||
|
// area.c
|
||||||
|
#define areaClass L"libui_uiAreaClass"
|
||||||
|
extern void processAreaMessage(HWND, MSG *);
|
||||||
|
extern ATOM registerAreaClass(HICON, HCURSOR);
|
||||||
|
extern void unregisterAreaClass(void);
|
||||||
|
|
||||||
|
// draw.c
|
||||||
|
extern HRESULT initDraw(void);
|
||||||
|
extern void uninitDraw(void);
|
||||||
|
extern ID2D1HwndRenderTarget *makeHWNDRenderTarget(HWND hwnd);
|
||||||
|
extern uiDrawContext *newContext(ID2D1RenderTarget *);
|
||||||
|
extern void freeContext(uiDrawContext *);
|
||||||
|
|
Loading…
Reference in New Issue