introduce MwFreeWidget
All checks were successful
pyrite-dev/milsko/pipeline/head This commit looks good
All checks were successful
pyrite-dev/milsko/pipeline/head This commit looks good
This commit is contained in:
parent
3779b2e0db
commit
4bf321f3a2
6 changed files with 47 additions and 6 deletions
|
|
@ -375,6 +375,14 @@ MWDECL void MWAPI MwSetUser(MwWidget handle, void* user);
|
||||||
*/
|
*/
|
||||||
MWDECL void* MWAPI MwGetUser(MwWidget handle);
|
MWDECL void* MWAPI MwGetUser(MwWidget handle);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Free the widget
|
||||||
|
* @param handle Widget
|
||||||
|
* @warning This is used internally!
|
||||||
|
* @note You can call this on toplevel widget safely if you're sure no event loops will be ran, e.g. after `MwLoop`.
|
||||||
|
*/
|
||||||
|
MWDECL void MWAPI MwFreeWidget(MwWidget handle);
|
||||||
|
|
||||||
#ifdef _MILSKO
|
#ifdef _MILSKO
|
||||||
MWDECL void MwForceRender_Internal(MwWidget handle);
|
MWDECL void MwForceRender_Internal(MwWidget handle);
|
||||||
MWDECL void MwForceRender2_Internal(MwWidget handle, void* ptr);
|
MWDECL void MwForceRender2_Internal(MwWidget handle, void* ptr);
|
||||||
|
|
|
||||||
19
milsko.xml
19
milsko.xml
|
|
@ -518,6 +518,25 @@
|
||||||
<widget name="handle" />
|
<widget name="handle" />
|
||||||
</arguments>
|
</arguments>
|
||||||
</function>
|
</function>
|
||||||
|
<function name="MwSetUser">
|
||||||
|
<arguments>
|
||||||
|
<widget name="handle" />
|
||||||
|
<pointer name="user" />
|
||||||
|
</arguments>
|
||||||
|
</function>
|
||||||
|
<function name="MwGetUser">
|
||||||
|
<return>
|
||||||
|
<pointer />
|
||||||
|
</return>
|
||||||
|
<arguments>
|
||||||
|
<widget name="handle" />
|
||||||
|
</arguments>
|
||||||
|
</function>
|
||||||
|
<function name="MwFreeWidget">
|
||||||
|
<arguments>
|
||||||
|
<widget name="handle" />
|
||||||
|
</arguments>
|
||||||
|
</function>
|
||||||
</functions>
|
</functions>
|
||||||
</header>
|
</header>
|
||||||
<header name="Dialog/FileChooser">
|
<header name="Dialog/FileChooser">
|
||||||
|
|
|
||||||
|
|
@ -1164,6 +1164,9 @@ Cursor MwLLX11CreateCursor(Display* display, MwCursor* image, MwCursor* mask) {
|
||||||
XDestroyImage(cimage);
|
XDestroyImage(cimage);
|
||||||
XDestroyImage(cmask);
|
XDestroyImage(cmask);
|
||||||
|
|
||||||
|
XFreeGC(display, imagegc);
|
||||||
|
XFreeGC(display, maskgc);
|
||||||
|
|
||||||
return cur;
|
return cur;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -280,6 +280,8 @@ static MwWidget MwCreateWidget_Internal(MwClass widget_class, const char* name,
|
||||||
{
|
{
|
||||||
h->root_font = NULL;
|
h->root_font = NULL;
|
||||||
h->root_boldfont = NULL;
|
h->root_boldfont = NULL;
|
||||||
|
h->root_monofont = NULL;
|
||||||
|
h->root_boldmonofont = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(h->parent != NULL) MwDispatch(h->parent, children_update);
|
if(h->parent != NULL) MwDispatch(h->parent, children_update);
|
||||||
|
|
@ -324,7 +326,7 @@ MwWidget MwVaListCreateWidget(MwClass widget_class, const char* name, MwWidget p
|
||||||
return h;
|
return h;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void MwFreeWidget(MwWidget handle) {
|
void MwFreeWidget(MwWidget handle) {
|
||||||
int i;
|
int i;
|
||||||
MwWidget root = handle;
|
MwWidget root = handle;
|
||||||
MwWidget w;
|
MwWidget w;
|
||||||
|
|
@ -351,6 +353,7 @@ static void MwFreeWidget(MwWidget handle) {
|
||||||
for(i = 0; i < arrlen(handle->children); i++) {
|
for(i = 0; i < arrlen(handle->children); i++) {
|
||||||
MwFreeWidget(handle->children[i]);
|
MwFreeWidget(handle->children[i]);
|
||||||
}
|
}
|
||||||
|
arrfree(handle->children);
|
||||||
|
|
||||||
while(root->parent != NULL) root = root->parent;
|
while(root->parent != NULL) root = root->parent;
|
||||||
for(i = 0; i < arrlen(root->tick_list); i++) {
|
for(i = 0; i < arrlen(root->tick_list); i++) {
|
||||||
|
|
@ -384,6 +387,8 @@ static void MwFreeWidget(MwWidget handle) {
|
||||||
|
|
||||||
if(handle->root_font != NULL) MwFontFree(handle->root_font);
|
if(handle->root_font != NULL) MwFontFree(handle->root_font);
|
||||||
if(handle->root_boldfont != NULL) MwFontFree(handle->root_boldfont);
|
if(handle->root_boldfont != NULL) MwFontFree(handle->root_boldfont);
|
||||||
|
if(handle->root_monofont != NULL) MwFontFree(handle->root_monofont);
|
||||||
|
if(handle->root_boldmonofont != NULL) MwFontFree(handle->root_boldmonofont);
|
||||||
|
|
||||||
free(handle);
|
free(handle);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -309,6 +309,8 @@ static void draw(MwWidget handle) {
|
||||||
r.width = w;
|
r.width = w;
|
||||||
MwLLDrawPixmap(handle->lowlevel, &r, px);
|
MwLLDrawPixmap(handle->lowlevel, &r, px);
|
||||||
|
|
||||||
|
free(raw);
|
||||||
|
|
||||||
MwLLDestroyPixmap(px);
|
MwLLDestroyPixmap(px);
|
||||||
} else {
|
} else {
|
||||||
r.width -= MwGetInteger(handle, MwNleftPadding);
|
r.width -= MwGetInteger(handle, MwNleftPadding);
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ char* int_params[] = {/*MwNx, MwNy, MwNwidth, MwNheight,*/ MwNorientation,
|
||||||
unsigned long maxxes[] = {UINT8_MAX, UINT16_MAX, UINT32_MAX, UINT64_MAX};
|
unsigned long maxxes[] = {UINT8_MAX, UINT16_MAX, UINT32_MAX, UINT64_MAX};
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
int i;
|
int i, j = 0;
|
||||||
char input;
|
char input;
|
||||||
MwWidget window, widget;
|
MwWidget window, widget;
|
||||||
unsigned long upper_limit;
|
unsigned long upper_limit;
|
||||||
|
|
@ -49,14 +49,14 @@ get_input:
|
||||||
|
|
||||||
window = MwCreateWidget(MwWindowClass, "window", NULL, 0, 0, 400, 400);
|
window = MwCreateWidget(MwWindowClass, "window", NULL, 0, 0, 400, 400);
|
||||||
|
|
||||||
while(MwPending(window)) {
|
while(MwPending(window) && j < 50) {
|
||||||
int class_num = rand() % (sizeof(classes) / sizeof(cls_pair_t));
|
int class_num = rand() % (sizeof(classes) / sizeof(cls_pair_t));
|
||||||
widget = MwCreateWidget(*classes[class_num].cls, classes[class_num].name, window, 0, 0, 100, 100);
|
widget = MwCreateWidget(*classes[class_num].cls, classes[class_num].name, window, 0, 0, 100, 100);
|
||||||
|
|
||||||
printf("%s\n", classes[class_num].name);
|
printf("%s\n", classes[class_num].name);
|
||||||
/* apply int params with random scale */
|
/* apply int params with random scale */
|
||||||
for(i = 0; i < (sizeof(int_params) / sizeof(void*)); i++) {
|
for(i = 0; i < (sizeof(int_params) / sizeof(void*)); i++) {
|
||||||
unsigned long number = rand() % UINT8_MAX;
|
unsigned long number = rand() % upper_limit;
|
||||||
printf("> %s = %lu\n", int_params[i], number);
|
printf("> %s = %lu\n", int_params[i], number);
|
||||||
MwVaApply(widget, int_params[i], number, NULL);
|
MwVaApply(widget, int_params[i], number, NULL);
|
||||||
}
|
}
|
||||||
|
|
@ -65,5 +65,9 @@ get_input:
|
||||||
MwDestroyWidget(widget);
|
MwDestroyWidget(widget);
|
||||||
|
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
||||||
|
j++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MwFreeWidget(window);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue