Removed what was left in the main folder. We are so fucking close..
This commit is contained in:
parent
a14112861f
commit
e3c64dc0d1
73
GNUbase.mk
73
GNUbase.mk
|
@ -1,73 +0,0 @@
|
|||
# 22 april 2015
|
||||
|
||||
OUTBASE = new
|
||||
OUTDIR = out
|
||||
OBJDIR = .obj
|
||||
|
||||
IDLFILES = \
|
||||
$(baseIDLFILES)
|
||||
|
||||
xHFILES = \
|
||||
uipriv.h \
|
||||
$(IDLFILES:%.idl=$(OUTDIR)/%.h) \
|
||||
$(baseHFILES)
|
||||
|
||||
OFILES = \
|
||||
$(baseCFILES:%.c=$(OBJDIR)/%.o) \
|
||||
$(baseMFILES:%.m=$(OBJDIR)/%.o) \
|
||||
$(baseRCFILES:%.rc=$(OBJDIR)/%.o)
|
||||
|
||||
xCFLAGS = \
|
||||
-g \
|
||||
-Wall -Wextra \
|
||||
-Wno-unused-parameter \
|
||||
-Wno-switch \
|
||||
--std=c99 \
|
||||
$(CFLAGS) \
|
||||
$(archmflag) \
|
||||
$(baseCFLAGS)
|
||||
|
||||
# windres doesn't support -m
|
||||
xRCFLAGS = \
|
||||
$(RCFLAGS) \
|
||||
$(baseRCFLAGS)
|
||||
|
||||
xLDFLAGS = \
|
||||
-g \
|
||||
$(LDFLAGS) \
|
||||
$(archmflag) \
|
||||
$(baseLDFLAGS)
|
||||
|
||||
OUT = $(OUTDIR)/$(OUTBASE)$(baseSUFFIX)
|
||||
|
||||
$(OUT): $(OFILES) | $(OUTDIR)/.phony
|
||||
@$(CC) -o $(OUT) $(OFILES) $(xLDFLAGS)
|
||||
@echo ====== Linked $(OUT)
|
||||
|
||||
.SECONDEXPANSION:
|
||||
$(OBJDIR)/%.o: %.c $(xHFILES) | $$(dir $$@).phony
|
||||
@$(CC) -o $@ -c $< $(xCFLAGS)
|
||||
@echo ====== Compiled $<
|
||||
|
||||
$(OBJDIR)/%.o: %.m $(xHFILES) | $$(dir $$@).phony
|
||||
@$(CC) -o $@ -c $< $(xCFLAGS)
|
||||
@echo ====== Compiled $<
|
||||
|
||||
$(OBJDIR)/%.o: %.rc $(xHFILES) | $$(dir $$@).phony
|
||||
@$(RC) $(xRCFLAGS) $< $@
|
||||
@echo ====== Compiled $<
|
||||
|
||||
# see http://www.cmcrossroads.com/article/making-directories-gnu-make
|
||||
%/.phony:
|
||||
@mkdir -p $(dir $@)
|
||||
@touch $@
|
||||
.PRECIOUS: %/.phony
|
||||
|
||||
$(OUTDIR)/%.h: %.idl tools/idl2h.go | $(OUTDIR)/.phony
|
||||
@go run tools/idl2h.go -extern _UI_EXTERN -guard __UI_UI_H__ < $< > $@
|
||||
@echo ====== Generated `basename $@`
|
||||
.PRECIOUS: $(OUTDIR)/%.h
|
||||
|
||||
clean:
|
||||
rm -rf $(OUTDIR) $(OBJDIR) z*
|
||||
.PHONY: clean
|
52
GNUmakefile
52
GNUmakefile
|
@ -1,52 +0,0 @@
|
|||
# 22 april 2015
|
||||
|
||||
# MAME does this so :/
|
||||
ifeq ($(OS),Windows_NT)
|
||||
OS = windows
|
||||
endif
|
||||
|
||||
ifndef OS
|
||||
UNAME = $(shell uname -s)
|
||||
ifeq ($(UNAME),Darwin)
|
||||
OS = darwin
|
||||
else
|
||||
OS = unix
|
||||
endif
|
||||
endif
|
||||
|
||||
include $(OS)/GNUmakeinc.mk
|
||||
|
||||
baseIDLFILES = \
|
||||
ui.idl
|
||||
# ui_$(OS).idl
|
||||
|
||||
baseHFILES = \
|
||||
uipriv.h \
|
||||
ui_$(OS).h \
|
||||
$(osHFILES)
|
||||
|
||||
baseCFILES = \
|
||||
control.c \
|
||||
menu.c \
|
||||
ptrarray.c \
|
||||
shouldquit.c \
|
||||
types.c \
|
||||
$(osCFILES)
|
||||
|
||||
baseMFILES = $(osMFILES)
|
||||
|
||||
baseRCFILES = $(osRCFILES)
|
||||
|
||||
baseCFLAGS = $(osCFLAGS)
|
||||
baseLDFLAGS = \
|
||||
-shared \
|
||||
$(osLDWarnUndefinedFlags) \
|
||||
$(osLDFLAGS)
|
||||
baseRCFLAGS = $(osRCFLAGS)
|
||||
baseSUFFIX = $(osLIBSUFFIX)
|
||||
|
||||
include GNUbase.mk
|
||||
|
||||
test: $(OUT)
|
||||
@$(MAKE) -f GNUmaketest.mk osLIB=$(OUT) osEXESUFFIX=$(osEXESUFFIX) CC=$(CC) archmflag=$(archmflag)
|
||||
.PHONY: test
|
|
@ -1,15 +0,0 @@
|
|||
# 22 april 2015
|
||||
# should never be invoked directly, only ever from the main makefile
|
||||
|
||||
include test/GNUmakeinc.mk
|
||||
|
||||
baseHFILES = \
|
||||
$(testHFILES)
|
||||
|
||||
baseCFILES = $(testCFILES)
|
||||
|
||||
baseCFLAGS = $(testCFLAGS)
|
||||
baseLDFLAGS = $(osLIB) $(testLDFLAGS)
|
||||
baseSUFFIX = $(osEXESUFFIX)
|
||||
|
||||
include GNUbase.mk
|
153
control.c
153
control.c
|
@ -1,153 +0,0 @@
|
|||
// 26 may 2015
|
||||
#include "out/ui.h"
|
||||
#include "uipriv.h"
|
||||
|
||||
struct controlBase {
|
||||
uiControl *parent;
|
||||
int hidden;
|
||||
int disabled;
|
||||
};
|
||||
|
||||
static uintmax_t type_uiControl = 0;
|
||||
|
||||
uintmax_t uiTypeControl(void)
|
||||
{
|
||||
if (type_uiControl == 0)
|
||||
type_uiControl = uiRegisterType("uiControl", 0, 0);
|
||||
return type_uiControl;
|
||||
}
|
||||
|
||||
#define controlBase(c) ((struct controlBase *) (c->Internal))
|
||||
|
||||
static void controlBaseDestroy(uiControl *c)
|
||||
{
|
||||
struct controlBase *cb = controlBase(c);
|
||||
|
||||
if (cb->parent != NULL)
|
||||
complain("attempt to destroy uiControl %p while it has a parent", c);
|
||||
uiControlCommitDestroy(c);
|
||||
uiFree(cb);
|
||||
uiFree(c);
|
||||
}
|
||||
|
||||
static uiControl *controlBaseParent(uiControl *c)
|
||||
{
|
||||
struct controlBase *cb = controlBase(c);
|
||||
|
||||
return cb->parent;
|
||||
}
|
||||
|
||||
static void controlBaseSetParent(uiControl *c, uiControl *parent)
|
||||
{
|
||||
struct controlBase *cb = controlBase(c);
|
||||
|
||||
if (parent != NULL && cb->parent != NULL)
|
||||
complain("attempt to reparent uiControl %p (has parent %p, attempt to give parent %p)", c, cb->parent, parent);
|
||||
if (parent == NULL && cb->parent == NULL)
|
||||
complain("attempt to double unparent uiControl %p", c);
|
||||
// this must come first; GTK+ CommitSetParent() needs the old parent
|
||||
uiControlCommitSetParent(c, parent);
|
||||
cb->parent = parent;
|
||||
// for situations such as where the old parent was disabled but the new one is not, etc.
|
||||
uiControlUpdateState(c);
|
||||
}
|
||||
|
||||
static void controlBaseQueueResize(uiControl *c)
|
||||
{
|
||||
queueResize(c);
|
||||
}
|
||||
|
||||
static int controlBaseContainerVisible(uiControl *c)
|
||||
{
|
||||
struct controlBase *cb = controlBase(c);
|
||||
|
||||
if (cb->hidden)
|
||||
return 0;
|
||||
if (cb->parent == NULL)
|
||||
return 1;
|
||||
return uiControlContainerVisible(cb->parent);
|
||||
}
|
||||
|
||||
static void controlBaseShow(uiControl *c)
|
||||
{
|
||||
struct controlBase *cb = controlBase(c);
|
||||
|
||||
cb->hidden = 0;
|
||||
uiControlUpdateState(c);
|
||||
}
|
||||
|
||||
static void controlBaseHide(uiControl *c)
|
||||
{
|
||||
struct controlBase *cb = controlBase(c);
|
||||
|
||||
cb->hidden = 1;
|
||||
uiControlUpdateState(c);
|
||||
}
|
||||
|
||||
static int controlBaseContainerEnabled(uiControl *c)
|
||||
{
|
||||
struct controlBase *cb = controlBase(c);
|
||||
|
||||
if (cb->disabled)
|
||||
return 0;
|
||||
if (cb->parent == NULL)
|
||||
return 1;
|
||||
return uiControlContainerEnabled(cb->parent);
|
||||
}
|
||||
|
||||
static void controlBaseEnable(uiControl *c)
|
||||
{
|
||||
struct controlBase *cb = controlBase(c);
|
||||
|
||||
cb->disabled = 0;
|
||||
uiControlUpdateState(c);
|
||||
}
|
||||
|
||||
static void controlBaseDisable(uiControl *c)
|
||||
{
|
||||
struct controlBase *cb = controlBase(c);
|
||||
|
||||
cb->disabled = 1;
|
||||
uiControlUpdateState(c);
|
||||
}
|
||||
|
||||
static void controlBaseUpdateState(uiControl *c)
|
||||
{
|
||||
if (uiControlContainerVisible(c))
|
||||
uiControlCommitShow(c);
|
||||
else
|
||||
uiControlCommitHide(c);
|
||||
if (uiControlContainerEnabled(c))
|
||||
uiControlCommitEnable(c);
|
||||
else
|
||||
uiControlCommitDisable(c);
|
||||
uiControlContainerUpdateState(c);
|
||||
// and queue a resize, just in case we showed/hid something
|
||||
uiControlQueueResize(c);
|
||||
}
|
||||
|
||||
static void controlBaseContainerUpdateState(uiControl *c)
|
||||
{
|
||||
// by default not a container; do nothing
|
||||
}
|
||||
|
||||
uiControl *uiNewControl(uintmax_t type)
|
||||
{
|
||||
uiControl *c;
|
||||
|
||||
c = uiControl(newTyped(type));
|
||||
uiControl(c)->Internal = uiNew(struct controlBase);
|
||||
uiControl(c)->Destroy = controlBaseDestroy;
|
||||
uiControl(c)->Parent = controlBaseParent;
|
||||
uiControl(c)->SetParent = controlBaseSetParent;
|
||||
uiControl(c)->QueueResize = controlBaseQueueResize;
|
||||
uiControl(c)->ContainerVisible = controlBaseContainerVisible;
|
||||
uiControl(c)->Show = controlBaseShow;
|
||||
uiControl(c)->Hide = controlBaseHide;
|
||||
uiControl(c)->ContainerEnabled = controlBaseContainerEnabled;
|
||||
uiControl(c)->Enable = controlBaseEnable;
|
||||
uiControl(c)->Disable = controlBaseDisable;
|
||||
uiControl(c)->UpdateState = controlBaseUpdateState;
|
||||
uiControl(c)->ContainerUpdateState = controlBaseContainerUpdateState;
|
||||
return uiControl(c);
|
||||
}
|
19
menu.c
19
menu.c
|
@ -1,19 +0,0 @@
|
|||
// 29 may 2015
|
||||
#include "out/ui.h"
|
||||
|
||||
static uintmax_t type_uiMenu = 0;
|
||||
static uintmax_t type_uiMenuItem = 0;
|
||||
|
||||
uintmax_t uiTypeMenu(void)
|
||||
{
|
||||
if (type_uiMenu == 0)
|
||||
type_uiMenu = uiRegisterType("uiMenu", 0, 0);
|
||||
return type_uiMenu;
|
||||
}
|
||||
|
||||
uintmax_t uiTypeMenuItem(void)
|
||||
{
|
||||
if (type_uiMenuItem == 0)
|
||||
type_uiMenuItem = uiRegisterType("uiMenuItem", 0, 0);
|
||||
return type_uiMenuItem;
|
||||
}
|
49
ptrarray.c
49
ptrarray.c
|
@ -1,49 +0,0 @@
|
|||
// 5 may 2015
|
||||
#include <string.h>
|
||||
#include "out/ui.h"
|
||||
#include "uipriv.h"
|
||||
|
||||
struct ptrArray *newPtrArray(void)
|
||||
{
|
||||
return uiNew(struct ptrArray);
|
||||
}
|
||||
|
||||
void ptrArrayDestroy(struct ptrArray *p)
|
||||
{
|
||||
if (p->len != 0)
|
||||
complain("attempt to destroy ptrarray %p while it still has pointers inside", p);
|
||||
if (p->ptrs != NULL) // array was created but nothing was ever put inside
|
||||
uiFree(p->ptrs);
|
||||
uiFree(p);
|
||||
}
|
||||
|
||||
#define grow 32
|
||||
|
||||
void ptrArrayAppend(struct ptrArray *p, void *d)
|
||||
{
|
||||
ptrArrayInsertAt(p, p->len, d);
|
||||
}
|
||||
|
||||
void ptrArrayInsertAt(struct ptrArray *p, uintmax_t i, void *d)
|
||||
{
|
||||
if (i > p->len)
|
||||
complain("index out of range in ptrArrayInsertAt()");
|
||||
if (p->len >= p->cap) {
|
||||
p->cap += grow;
|
||||
p->ptrs = (void **) uiRealloc(p->ptrs, p->cap * sizeof (void *), "void *[]");
|
||||
}
|
||||
// thanks to ValleyBell
|
||||
memmove(&(p->ptrs[i + 1]), &(p->ptrs[i]), (p->len - i) * sizeof (void *));
|
||||
p->ptrs[i] = d;
|
||||
p->len++;
|
||||
}
|
||||
|
||||
void ptrArrayDelete(struct ptrArray *p, uintmax_t i)
|
||||
{
|
||||
if (i >= p->len)
|
||||
complain("index out of range in ptrArrayRemove()");
|
||||
// thanks to ValleyBell
|
||||
memmove(&(p->ptrs[i]), &(p->ptrs[i + 1]), (p->len - i - 1) * sizeof (void *));
|
||||
p->ptrs[p->len - 1] = NULL;
|
||||
p->len--;
|
||||
}
|
22
shouldquit.c
22
shouldquit.c
|
@ -1,22 +0,0 @@
|
|||
// 9 may 2015
|
||||
#include "out/ui.h"
|
||||
#include "uipriv.h"
|
||||
|
||||
static int defaultOnShouldQuit(void *data)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int (*onShouldQuit)(void *) = defaultOnShouldQuit;
|
||||
static void *onShouldQuitData;
|
||||
|
||||
void uiOnShouldQuit(int (*f)(void *), void *data)
|
||||
{
|
||||
onShouldQuit = f;
|
||||
onShouldQuitData = data;
|
||||
}
|
||||
|
||||
int shouldQuit(void)
|
||||
{
|
||||
return (*onShouldQuit)(onShouldQuitData);
|
||||
}
|
87
types.c
87
types.c
|
@ -1,87 +0,0 @@
|
|||
// 17 may 2015
|
||||
#include "out/ui.h"
|
||||
#include "uipriv.h"
|
||||
|
||||
struct typeinfo {
|
||||
const char *name;
|
||||
uintmax_t parent;
|
||||
size_t size;
|
||||
};
|
||||
|
||||
static struct ptrArray *types = NULL;
|
||||
|
||||
uintmax_t uiRegisterType(const char *name, uintmax_t parent, size_t size)
|
||||
{
|
||||
struct typeinfo *ti;
|
||||
|
||||
if (types == NULL) {
|
||||
types = newPtrArray();
|
||||
// reserve ID 0
|
||||
ptrArrayAppend(types, NULL);
|
||||
}
|
||||
ti = uiNew(struct typeinfo);
|
||||
ti->name = name;
|
||||
ti->parent = parent;
|
||||
ti->size = size;
|
||||
ptrArrayAppend(types, ti);
|
||||
return types->len - 1;
|
||||
}
|
||||
|
||||
void *uiIsA(void *p, uintmax_t id, int fail)
|
||||
{
|
||||
uiTyped *t;
|
||||
struct typeinfo *ti, *ti2;
|
||||
uintmax_t compareTo;
|
||||
|
||||
if (id == 0 || id >= types->len)
|
||||
complain("invalid type ID given to uiIsA()");
|
||||
t = (uiTyped *) p;
|
||||
compareTo = t->Type;
|
||||
if (compareTo == 0)
|
||||
complain("object %p has no type in uiIsA()", t);
|
||||
for (;;) {
|
||||
if (compareTo >= types->len)
|
||||
complain("invalid type ID in uiIsA()", t);
|
||||
if (compareTo == id)
|
||||
return t;
|
||||
ti = ptrArrayIndex(types, struct typeinfo *, compareTo);
|
||||
if (ti->parent == 0)
|
||||
break;
|
||||
compareTo = ti->parent;
|
||||
}
|
||||
if (fail) {
|
||||
ti = ptrArrayIndex(types, struct typeinfo *, id);
|
||||
ti2 = ptrArrayIndex(types, struct typeinfo *, t->Type);
|
||||
complain("object %p not a %s in uiIsA() (is a %s)", t, ti->name, ti2->name);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void uninitTypes(void)
|
||||
{
|
||||
struct typeinfo *ti;
|
||||
|
||||
if (types == NULL) // never initialized; do nothing
|
||||
return;
|
||||
// the first entry is NULL; get rid of it directly
|
||||
ptrArrayDelete(types, 0);
|
||||
while (types->len != 0) {
|
||||
ti = ptrArrayIndex(types, struct typeinfo *, 0);
|
||||
ptrArrayDelete(types, 0);
|
||||
uiFree(ti);
|
||||
}
|
||||
ptrArrayDestroy(types);
|
||||
}
|
||||
|
||||
uiTyped *newTyped(uintmax_t type)
|
||||
{
|
||||
struct typeinfo *ti;
|
||||
uiTyped *instance;
|
||||
|
||||
if (type == 0 || type >= types->len)
|
||||
complain("invalid type ID given to newTyped()");
|
||||
ti = ptrArrayIndex(types, struct typeinfo *, type);
|
||||
instance = (uiTyped *) uiAlloc(ti->size, ti->name);
|
||||
instance->Type = type;
|
||||
return instance;
|
||||
}
|
38
uipriv.h
38
uipriv.h
|
@ -1,38 +0,0 @@
|
|||
// 6 april 2015
|
||||
#include <stdlib.h>
|
||||
|
||||
#define uthash_fatal(msg) complain("uthash failed: %s", (msg))
|
||||
#define uthash_malloc(sz) uiAlloc((sz), "(uthash internal)")
|
||||
#define uthash_free(ptr,sz) uiFree((ptr))
|
||||
#include "uthash/uthash.h"
|
||||
|
||||
extern uiInitOptions options;
|
||||
|
||||
extern void *uiAlloc(size_t, const char *);
|
||||
#define uiNew(T) ((T *) uiAlloc(sizeof (T), #T))
|
||||
extern void *uiRealloc(void *, size_t, const char *);
|
||||
extern void uiFree(void *);
|
||||
|
||||
extern void complain(const char *, ...);
|
||||
|
||||
extern void queueResize(uiControl *);
|
||||
|
||||
// ptrarray.c
|
||||
struct ptrArray {
|
||||
void **ptrs;
|
||||
uintmax_t len;
|
||||
uintmax_t cap;
|
||||
};
|
||||
struct ptrArray *newPtrArray(void);
|
||||
void ptrArrayDestroy(struct ptrArray *);
|
||||
void ptrArrayAppend(struct ptrArray *, void *);
|
||||
void ptrArrayInsertAt(struct ptrArray *, uintmax_t, void *);
|
||||
void ptrArrayDelete(struct ptrArray *, uintmax_t);
|
||||
#define ptrArrayIndex(p, T, i) ((T) ((p)->ptrs[(i)]))
|
||||
|
||||
// shouldquit.c
|
||||
extern int shouldQuit(void);
|
||||
|
||||
// types.c
|
||||
extern void uninitTypes(void);
|
||||
extern uiTyped *newTyped(uintmax_t type);
|
|
@ -1,196 +0,0 @@
|
|||
// 27 may 2015
|
||||
#include "uipriv_windows.h"
|
||||
|
||||
HWND uiWindowsUtilCreateControlHWND(DWORD dwExStyle, LPCWSTR lpClassName, LPCWSTR lpWindowName, DWORD dwStyle, HINSTANCE hInstance, LPVOID lpParam, BOOL useStandardControlFont)
|
||||
{
|
||||
HWND hwnd;
|
||||
|
||||
hwnd = CreateWindowExW(dwExStyle,
|
||||
lpClassName, lpWindowName,
|
||||
dwStyle | WS_CHILD | WS_VISIBLE,
|
||||
0, 0,
|
||||
// use a nonzero initial size just in case some control breaks with a zero initial size
|
||||
100, 100,
|
||||
utilWindow, NULL, hInstance, lpParam);
|
||||
if (hwnd == NULL)
|
||||
logLastError("error creating window in uiWindowsUtilCreateControlHWND()");
|
||||
if (useStandardControlFont)
|
||||
SendMessageW(hwnd, WM_SETFONT, (WPARAM) hMessageFont, (LPARAM) TRUE);
|
||||
return hwnd;
|
||||
}
|
||||
|
||||
#define HWND(c) ((HWND) uiControlHandle((c)))
|
||||
|
||||
void uiWindowsUtilDestroy(HWND hwnd)
|
||||
{
|
||||
if (DestroyWindow(hwnd) == 0)
|
||||
logLastError("error destroying window in uiWindowsUtilDestroyWindow()");
|
||||
}
|
||||
|
||||
static void singleHWNDCommitDestroy(uiControl *c)
|
||||
{
|
||||
uiWindowsUtilDestroy(HWND(c));
|
||||
}
|
||||
|
||||
void uiWindowsUtilSetParent(HWND hwnd, uiControl *parent)
|
||||
{
|
||||
HWND newParent;
|
||||
|
||||
newParent = utilWindow;
|
||||
if (parent != NULL)
|
||||
newParent = HWND(parent);
|
||||
if (SetParent(hwnd, newParent) == 0)
|
||||
logLastError("error changing window parent in uiWindowsUtilSetParent()");
|
||||
}
|
||||
|
||||
static void singleHWNDCommitSetParent(uiControl *c, uiControl *parent)
|
||||
{
|
||||
uiWindowsUtilSetParent(HWND(c), parent);
|
||||
}
|
||||
|
||||
void uiWindowsUtilResize(HWND hwnd, intmax_t x, intmax_t y, intmax_t width, intmax_t height, uiSizing *d)
|
||||
{
|
||||
moveWindow(hwnd, x, y, width, height, d);
|
||||
}
|
||||
|
||||
static void singleHWNDResize(uiControl *c, intmax_t x, intmax_t y, intmax_t width, intmax_t height, uiSizing *d)
|
||||
{
|
||||
uiWindowsUtilResize(HWND(c), x, y, width, height, d);
|
||||
}
|
||||
|
||||
static uiSizing *singleHWNDSizing(uiControl *c)
|
||||
{
|
||||
// TODO see if we can make this take an HWND and the parent
|
||||
return uiWindowsSizing(c);
|
||||
}
|
||||
|
||||
void uiWindowsUtilShow(HWND hwnd)
|
||||
{
|
||||
ShowWindow(hwnd, SW_SHOW);
|
||||
}
|
||||
|
||||
static void singleHWNDCommitShow(uiControl *c)
|
||||
{
|
||||
uiWindowsUtilShow(HWND(c));
|
||||
}
|
||||
|
||||
void uiWindowsUtilHide(HWND hwnd)
|
||||
{
|
||||
ShowWindow(hwnd, SW_HIDE);
|
||||
}
|
||||
|
||||
static void singleHWNDCommitHide(uiControl *c)
|
||||
{
|
||||
uiWindowsUtilHide(HWND(c));
|
||||
}
|
||||
|
||||
void uiWindowsUtilEnable(HWND hwnd)
|
||||
{
|
||||
EnableWindow(hwnd, TRUE);
|
||||
}
|
||||
|
||||
static void singleHWNDCommitEnable(uiControl *c)
|
||||
{
|
||||
uiWindowsUtilEnable(HWND(c));
|
||||
}
|
||||
|
||||
void uiWindowsUtilDisable(HWND hwnd)
|
||||
{
|
||||
EnableWindow(hwnd, FALSE);
|
||||
}
|
||||
|
||||
static void singleHWNDCommitDisable(uiControl *c)
|
||||
{
|
||||
uiWindowsUtilDisable(HWND(c));
|
||||
}
|
||||
|
||||
uintptr_t uiWindowsUtilStartZOrder(HWND hwnd)
|
||||
{
|
||||
HWND insertAfter;
|
||||
DWORD le;
|
||||
|
||||
// see http://stackoverflow.com/questions/30491418/
|
||||
// also, the window at the beginning of the z-order has no previous window, so GetWindow() returns NULL
|
||||
// we have to differentiate these error states
|
||||
SetLastError(0);
|
||||
insertAfter = GetWindow(hwnd, GW_HWNDPREV);
|
||||
if (insertAfter == NULL) {
|
||||
le = GetLastError();
|
||||
SetLastError(le); // just in case
|
||||
if (le != 0)
|
||||
logLastError("error getting insert after window in uiWindowsUtilStartZOrder()");
|
||||
}
|
||||
return (uintptr_t) insertAfter;
|
||||
}
|
||||
|
||||
static uintptr_t singleHWNDStartZOrder(uiControl *c)
|
||||
{
|
||||
return uiWindowsUtilStartZOrder(HWND(c));
|
||||
}
|
||||
|
||||
uintptr_t uiWindowsUtilSetZOrder(HWND hwnd, uintptr_t insertAfter)
|
||||
{
|
||||
setWindowInsertAfter(hwnd, (HWND) insertAfter);
|
||||
return (uintptr_t) hwnd;
|
||||
}
|
||||
|
||||
static uintptr_t singleHWNDSetZOrder(uiControl *c, uintptr_t insertAfter)
|
||||
{
|
||||
return uiWindowsUtilSetZOrder(HWND(c), insertAfter);
|
||||
}
|
||||
|
||||
// TODO should disabled controls return 1? test tabbing across a tab with only disabled controls
|
||||
int uiWindowsUtilHasTabStops(HWND hwnd)
|
||||
{
|
||||
return (getStyle(hwnd) & WS_TABSTOP) != 0;
|
||||
}
|
||||
|
||||
static int singleHWNDHasTabStops(uiControl *c)
|
||||
{
|
||||
return uiWindowsUtilHasTabStops(HWND(c));
|
||||
}
|
||||
|
||||
void setSingleHWNDFuncs(uiControl *c)
|
||||
{
|
||||
uiControl(c)->CommitDestroy = singleHWNDCommitDestroy;
|
||||
uiControl(c)->CommitSetParent = singleHWNDCommitSetParent;
|
||||
uiControl(c)->Resize = singleHWNDResize;
|
||||
uiControl(c)->Sizing = singleHWNDSizing;
|
||||
uiControl(c)->CommitShow = singleHWNDCommitShow;
|
||||
uiControl(c)->CommitHide = singleHWNDCommitHide;
|
||||
uiControl(c)->CommitEnable = singleHWNDCommitEnable;
|
||||
uiControl(c)->CommitDisable = singleHWNDCommitDisable;
|
||||
uiControl(c)->StartZOrder = singleHWNDStartZOrder;
|
||||
uiControl(c)->SetZOrder = singleHWNDSetZOrder;
|
||||
uiControl(c)->HasTabStops = singleHWNDHasTabStops;
|
||||
}
|
||||
|
||||
uiControl *uiWindowsNewSingleHWNDControl(uintmax_t type)
|
||||
{
|
||||
uiControl *c;
|
||||
|
||||
c = uiNewControl(type);
|
||||
setSingleHWNDFuncs(c);
|
||||
return c;
|
||||
}
|
||||
|
||||
char *uiWindowsUtilText(HWND hwnd)
|
||||
{
|
||||
WCHAR *wtext;
|
||||
char *text;
|
||||
|
||||
wtext = windowText(hwnd);
|
||||
text = toUTF8(wtext);
|
||||
uiFree(wtext);
|
||||
return text;
|
||||
}
|
||||
|
||||
void uiWindowsUtilSetText(HWND hwnd, const char *text)
|
||||
{
|
||||
WCHAR *wtext;
|
||||
|
||||
wtext = toUTF16(text);
|
||||
if (SetWindowTextW(hwnd, wtext) == 0)
|
||||
logLastError("error setting control text in uiWindowsControlSetText()");
|
||||
uiFree(wtext);
|
||||
}
|
Loading…
Reference in New Issue