fix issue #5
This commit is contained in:
parent
32f09a9af2
commit
85994d42f1
6 changed files with 104 additions and 74 deletions
16
Makefile.pl
16
Makefile.pl
|
|
@ -223,7 +223,8 @@ foreach my $l (@library_targets) {
|
||||||
|
|
||||||
if ($l =~ /cocoa/) {
|
if ($l =~ /cocoa/) {
|
||||||
$s =~ s/$o$/.m/;
|
$s =~ s/$o$/.m/;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
$s =~ s/$o$/.c/;
|
$s =~ s/$o$/.c/;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -236,7 +237,7 @@ foreach my $l (@library_targets) {
|
||||||
}
|
}
|
||||||
print(OUT "\n");
|
print(OUT "\n");
|
||||||
print(OUT "\n");
|
print(OUT "\n");
|
||||||
if(param_get("examples")) {
|
if (param_get("examples")) {
|
||||||
print(OUT "examples: " . join(" ", @examples_targets) . "\n");
|
print(OUT "examples: " . join(" ", @examples_targets) . "\n");
|
||||||
print(OUT "\n");
|
print(OUT "\n");
|
||||||
foreach my $l (@examples_targets) {
|
foreach my $l (@examples_targets) {
|
||||||
|
|
@ -251,20 +252,21 @@ if(param_get("examples")) {
|
||||||
}
|
}
|
||||||
|
|
||||||
print(OUT
|
print(OUT
|
||||||
"${l}: ${s}${object_suffix} src/${library_prefix}Mw${library_suffix}\n"
|
"${l}: ${s}${object_suffix} src/${library_prefix}Mw${library_suffix}\n"
|
||||||
);
|
);
|
||||||
if (grep(/^cocoa$/, @backends)) {
|
if (grep(/^cocoa$/, @backends)) {
|
||||||
print(OUT
|
print(OUT
|
||||||
" \$(CC) -L./src \$\(LIBDIR) -o ${l} ${s}${object_suffix} -lMw ${math} ${libs}\n"
|
" \$(CC) -L./src \$\(LIBDIR) -o ${l} ${s}${object_suffix} -lMw ${math} ${libs}\n"
|
||||||
);
|
);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
print(OUT
|
print(OUT
|
||||||
" \$(CC) -L src -Wl,-R./src \$\(LIBDIR) -o ${l} ${s}${object_suffix} -lMw ${math} ${libs}\n"
|
" \$(CC) -L src -Wl,-R./src \$\(LIBDIR) -o ${l} ${s}${object_suffix} -lMw ${math} ${libs}\n"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
print(OUT "${s}${object_suffix}: ${s}.c\n");
|
print(OUT "${s}${object_suffix}: ${s}.c\n");
|
||||||
print(OUT
|
print(OUT
|
||||||
" \$(CC) -c \$\(INCDIR) -o ${s}${object_suffix} ${s}.c -lMw ${math}\n"
|
" \$(CC) -c \$\(INCDIR) -o ${s}${object_suffix} ${s}.c -lMw ${math}\n"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -101,6 +101,9 @@ struct _MwWidget {
|
||||||
MwWidget* tick_list;
|
MwWidget* tick_list;
|
||||||
|
|
||||||
int destroyed;
|
int destroyed;
|
||||||
|
|
||||||
|
void* root_font;
|
||||||
|
void* root_boldfont;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
97
src/core.c
97
src/core.c
|
|
@ -114,6 +114,19 @@ static void llclipboardhandler(MwLL handle, void* data) {
|
||||||
MwDispatchUserHandler(h, MwNclipboardHandler, data);
|
MwDispatchUserHandler(h, MwNclipboardHandler, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* if both of them are true
|
||||||
|
* 1. widget class is not NULL
|
||||||
|
* 2. parent is NULL
|
||||||
|
* or parent's widget class is NULL
|
||||||
|
*
|
||||||
|
* most likely this widget is first *visible* widget
|
||||||
|
*
|
||||||
|
* this macro is not used anywhere else - we could expose it if we have to
|
||||||
|
*
|
||||||
|
* (nishi)
|
||||||
|
*/
|
||||||
|
#define IsFirstVisible(handle) ((handle)->widget_class != NULL && ((handle)->parent == NULL || (handle)->parent->widget_class == NULL))
|
||||||
|
|
||||||
MwWidget MwCreateWidget(MwClass widget_class, const char* name, MwWidget parent, int x, int y, unsigned int width, unsigned int height) {
|
MwWidget MwCreateWidget(MwClass widget_class, const char* name, MwWidget parent, int x, int y, unsigned int width, unsigned int height) {
|
||||||
MwWidget h = malloc(sizeof(*h));
|
MwWidget h = malloc(sizeof(*h));
|
||||||
|
|
||||||
|
|
@ -186,6 +199,17 @@ MwWidget MwCreateWidget(MwClass widget_class, const char* name, MwWidget parent,
|
||||||
MwAddTickList(h);
|
MwAddTickList(h);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(USE_STB_TRUETYPE) || defined(USE_FREETYPE2)
|
||||||
|
if(IsFirstVisible(h)) {
|
||||||
|
h->root_font = MwFontLoad(MwTTFData, MwTTFDataSize);
|
||||||
|
h->root_boldfont = MwFontLoad(MwBoldTTFData, MwBoldTTFDataSize);
|
||||||
|
} else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
h->root_font = NULL;
|
||||||
|
h->root_boldfont = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if(h->parent != NULL) MwDispatch(h->parent, children_update);
|
if(h->parent != NULL) MwDispatch(h->parent, children_update);
|
||||||
|
|
||||||
return h;
|
return h;
|
||||||
|
|
@ -250,6 +274,9 @@ static void MwFreeWidget(MwWidget handle) {
|
||||||
arrfree(handle->destroy_queue);
|
arrfree(handle->destroy_queue);
|
||||||
arrfree(handle->tick_list);
|
arrfree(handle->tick_list);
|
||||||
|
|
||||||
|
if(handle->root_font != NULL) MwFontFree(handle->root_font);
|
||||||
|
if(handle->root_boldfont != NULL) MwFontFree(handle->root_boldfont);
|
||||||
|
|
||||||
free(handle);
|
free(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -507,8 +534,41 @@ const char* MwGetText(MwWidget handle, const char* key) {
|
||||||
return shget(handle->text, key);
|
return shget(handle->text, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void* inherit_void(MwWidget handle, const char* key) {
|
||||||
|
void* v;
|
||||||
|
|
||||||
|
if(handle->parent != NULL && (v = MwGetVoid(handle->parent, key)) != NULL) {
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
void* MwGetVoid(MwWidget handle, const char* key) {
|
void* MwGetVoid(MwWidget handle, const char* key) {
|
||||||
return shget(handle->data, key);
|
void* v = shget(handle->data, key);
|
||||||
|
|
||||||
|
if(v != NULL) return v;
|
||||||
|
|
||||||
|
#if defined(USE_STB_TRUETYPE) || defined(USE_FREETYPE2)
|
||||||
|
if(strcmp(key, MwNfont) == 0 || strcmp(key, MwNboldFont) == 0) {
|
||||||
|
v = inherit_void(handle, key);
|
||||||
|
|
||||||
|
if(v == NULL) {
|
||||||
|
MwWidget w = handle;
|
||||||
|
|
||||||
|
while(w != NULL && v == NULL) {
|
||||||
|
if(strcmp(key, MwNfont) == 0) {
|
||||||
|
v = w->root_font;
|
||||||
|
} else {
|
||||||
|
v = w->root_boldfont;
|
||||||
|
}
|
||||||
|
|
||||||
|
w = w->parent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MwVaApply(MwWidget handle, ...) {
|
void MwVaApply(MwWidget handle, ...) {
|
||||||
|
|
@ -576,43 +636,8 @@ void MwVaListApply(MwWidget handle, va_list va) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(USE_STB_TRUETYPE) || defined(USE_FREETYPE2)
|
|
||||||
static void set_font(MwWidget handle) {
|
|
||||||
void* f;
|
|
||||||
MwWidget h = handle;
|
|
||||||
while(h != NULL) {
|
|
||||||
if((f = MwGetVoid(h, MwNfont)) != NULL) {
|
|
||||||
MwSetVoid(handle, MwNfont, f);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
h = h->parent;
|
|
||||||
}
|
|
||||||
f = MwFontLoad(MwTTFData, MwTTFDataSize);
|
|
||||||
MwSetVoid(handle, MwNfont, f);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void set_boldfont(MwWidget handle) {
|
|
||||||
void* f;
|
|
||||||
MwWidget h = handle;
|
|
||||||
while(h != NULL) {
|
|
||||||
if((f = MwGetVoid(h, MwNboldFont)) != NULL) {
|
|
||||||
MwSetVoid(handle, MwNboldFont, f);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
h = h->parent;
|
|
||||||
}
|
|
||||||
f = MwFontLoad(MwBoldTTFData, MwBoldTTFDataSize);
|
|
||||||
MwSetVoid(handle, MwNboldFont, f);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void MwSetDefault(MwWidget handle) {
|
void MwSetDefault(MwWidget handle) {
|
||||||
if(handle->lowlevel != NULL) MwLLSetCursor(handle->lowlevel, &MwCursorDefault, &MwCursorDefaultMask);
|
if(handle->lowlevel != NULL) MwLLSetCursor(handle->lowlevel, &MwCursorDefault, &MwCursorDefaultMask);
|
||||||
|
|
||||||
#if defined(USE_STB_TRUETYPE) || defined(USE_FREETYPE2)
|
|
||||||
set_font(handle);
|
|
||||||
set_boldfont(handle);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MwHideCursor(MwWidget handle) {
|
void MwHideCursor(MwWidget handle) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue