mirror of
https://gitea.nishi.boats/pyrite-dev/milsko
synced 2026-01-11 03:43:29 +00:00
add MwReparent
git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@726 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
@@ -8,7 +8,7 @@ void ok(MwWidget handle, void* user, void* call) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void spawn(MwWidget handle, void* user, void* call) {
|
void spawn(MwWidget handle, void* user, void* call) {
|
||||||
MwWidget mb = MwMessageBox(handle, "news has arrived!", "title", MwMB_ICONNEWS | MwMB_BUTTONOK);
|
MwWidget mb = MwMessageBox(user, "news has arrived!", "title", MwMB_ICONNEWS | MwMB_BUTTONOK);
|
||||||
|
|
||||||
(void)handle;
|
(void)handle;
|
||||||
(void)call;
|
(void)call;
|
||||||
|
|||||||
@@ -300,6 +300,13 @@ MWDECL MwWidget MwGetParent(MwWidget handle);
|
|||||||
*/
|
*/
|
||||||
MWDECL void MwShow(MwWidget handle, int toggle);
|
MWDECL void MwShow(MwWidget handle, int toggle);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Reparents widget
|
||||||
|
* @param handle Widget
|
||||||
|
* @param new_parent New parent
|
||||||
|
*/
|
||||||
|
MWDECL void MwReparent(MwWidget handle, MwWidget new_parent);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
23
src/core.c
23
src/core.c
@@ -272,8 +272,14 @@ static void clean_destroy_queue(MwWidget handle) {
|
|||||||
|
|
||||||
int MwStep(MwWidget handle) {
|
int MwStep(MwWidget handle) {
|
||||||
int i;
|
int i;
|
||||||
|
MwWidget* widgets = NULL;
|
||||||
if(setjmp(handle->before_step)) return 0;
|
if(setjmp(handle->before_step)) return 0;
|
||||||
for(i = 0; i < arrlen(handle->children); i++) MwStep(handle->children[i]);
|
for(i = 0; i < arrlen(handle->children); i++) {
|
||||||
|
arrput(widgets, handle->children[i]);
|
||||||
|
}
|
||||||
|
for(i = 0; i < arrlen(widgets); i++) MwStep(widgets[i]);
|
||||||
|
|
||||||
|
arrfree(widgets);
|
||||||
|
|
||||||
handle->prop_event = 0;
|
handle->prop_event = 0;
|
||||||
if(handle->lowlevel != NULL && MwLLPending(handle->lowlevel)) MwLLNextEvent(handle->lowlevel);
|
if(handle->lowlevel != NULL && MwLLPending(handle->lowlevel)) MwLLNextEvent(handle->lowlevel);
|
||||||
@@ -639,3 +645,18 @@ int MwLibraryInit(void) {
|
|||||||
void MwShow(MwWidget handle, int toggle) {
|
void MwShow(MwWidget handle, int toggle) {
|
||||||
MwLLShow(handle->lowlevel, toggle);
|
MwLLShow(handle->lowlevel, toggle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MwReparent(MwWidget handle, MwWidget new_parent) {
|
||||||
|
if(handle->parent != NULL) {
|
||||||
|
int i;
|
||||||
|
for(i = 0; i < arrlen(handle->parent->children); i++) {
|
||||||
|
if(handle->parent->children[i] == handle) {
|
||||||
|
arrdel(handle->parent->children, i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
handle->parent = new_parent;
|
||||||
|
arrput(new_parent->children, handle);
|
||||||
|
}
|
||||||
|
|||||||
@@ -339,29 +339,28 @@ color_picker_t* color_picker_setup(MwWidget parent, int w, int h) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
MwWidget MwColorPicker(MwWidget handle, const char* title) {
|
MwWidget MwColorPicker(MwWidget handle, const char* title) {
|
||||||
MwPoint p;
|
|
||||||
color_picker_t* wheel;
|
color_picker_t* wheel;
|
||||||
MwWidget window;
|
MwWidget window;
|
||||||
MwSizeHints sh;
|
MwSizeHints sh;
|
||||||
int ww = handle == NULL ? 0 : MwGetInteger(handle, MwNwidth);
|
|
||||||
int wh = handle == NULL ? 0 : MwGetInteger(handle, MwNheight);
|
|
||||||
int wx;
|
int wx;
|
||||||
int wy;
|
int wy;
|
||||||
|
|
||||||
p.x = (ww - WIN_SIZE) / 2;
|
if(handle == NULL) {
|
||||||
p.y = (wh - WIN_SIZE) / 2;
|
wx = wy = MwDEFAULT;
|
||||||
|
} else {
|
||||||
wx = wy = 0;
|
wx = MwGetInteger(handle, MwNx) + (MwGetInteger(handle, MwNwidth) - WIN_SIZE) / 2;
|
||||||
if(handle == NULL) wx = wy = MwDEFAULT;
|
wy = MwGetInteger(handle, MwNy) + (MwGetInteger(handle, MwNheight) - WIN_SIZE) / 2;
|
||||||
|
}
|
||||||
|
|
||||||
sh.min_width = sh.max_width = WIN_SIZE;
|
sh.min_width = sh.max_width = WIN_SIZE;
|
||||||
sh.min_height = sh.max_height = WIN_SIZE;
|
sh.min_height = sh.max_height = WIN_SIZE;
|
||||||
|
|
||||||
window = MwVaCreateWidget(MwWindowClass, "main", handle, wx, wy,
|
window = MwVaCreateWidget(MwWindowClass, "main", NULL, wx, wy,
|
||||||
WIN_SIZE, WIN_SIZE,
|
WIN_SIZE, WIN_SIZE,
|
||||||
MwNtitle, title,
|
MwNtitle, title,
|
||||||
MwNsizeHints, &sh,
|
MwNsizeHints, &sh,
|
||||||
NULL);
|
NULL);
|
||||||
|
if(handle != NULL) MwReparent(window, handle);
|
||||||
|
|
||||||
wheel = color_picker_setup(window, WIN_SIZE, WIN_SIZE);
|
wheel = color_picker_setup(window, WIN_SIZE, WIN_SIZE);
|
||||||
|
|
||||||
@@ -370,7 +369,6 @@ MwWidget MwColorPicker(MwWidget handle, const char* title) {
|
|||||||
MwAddTickList(window);
|
MwAddTickList(window);
|
||||||
|
|
||||||
MwLLBeginStateChange(window->lowlevel);
|
MwLLBeginStateChange(window->lowlevel);
|
||||||
if(handle != NULL) MwLLDetach(window->lowlevel, &p);
|
|
||||||
MwLLMakePopup(window->lowlevel, handle == NULL ? NULL : handle->lowlevel);
|
MwLLMakePopup(window->lowlevel, handle == NULL ? NULL : handle->lowlevel);
|
||||||
MwLLEndStateChange(window->lowlevel);
|
MwLLEndStateChange(window->lowlevel);
|
||||||
|
|
||||||
|
|||||||
@@ -458,9 +458,6 @@ static void scan(MwWidget handle, const char* path, int record) {
|
|||||||
|
|
||||||
MwWidget MwFileChooser(MwWidget handle, const char* title) {
|
MwWidget MwFileChooser(MwWidget handle, const char* title) {
|
||||||
MwWidget window;
|
MwWidget window;
|
||||||
MwPoint p;
|
|
||||||
int ww = handle == NULL ? 0 : MwGetInteger(handle, MwNwidth);
|
|
||||||
int wh = handle == NULL ? 0 : MwGetInteger(handle, MwNheight);
|
|
||||||
int w, h;
|
int w, h;
|
||||||
filechooser_t* fc = malloc(sizeof(*fc));
|
filechooser_t* fc = malloc(sizeof(*fc));
|
||||||
char* path;
|
char* path;
|
||||||
@@ -473,15 +470,17 @@ MwWidget MwFileChooser(MwWidget handle, const char* title) {
|
|||||||
w = 700;
|
w = 700;
|
||||||
h = w * 2 / 3;
|
h = w * 2 / 3;
|
||||||
|
|
||||||
p.x = (ww - w) / 2;
|
if(handle == NULL) {
|
||||||
p.y = (wh - h) / 2;
|
wx = wy = MwDEFAULT;
|
||||||
|
} else {
|
||||||
|
wx = MwGetInteger(handle, MwNx) + (MwGetInteger(handle, MwNwidth) - w) / 2;
|
||||||
|
wy = MwGetInteger(handle, MwNy) + (MwGetInteger(handle, MwNheight) - h) / 2;
|
||||||
|
}
|
||||||
|
|
||||||
wx = wy = 0;
|
window = MwVaCreateWidget(MwWindowClass, "filechooser", NULL, wx, wy, w, h,
|
||||||
if(handle == NULL) wx = wy = MwDEFAULT;
|
|
||||||
|
|
||||||
window = MwVaCreateWidget(MwWindowClass, "filechooser", handle, wx, wy, w, h,
|
|
||||||
MwNtitle, title,
|
MwNtitle, title,
|
||||||
NULL);
|
NULL);
|
||||||
|
if(handle != NULL) MwReparent(window, handle);
|
||||||
|
|
||||||
fc->history_seek = 0;
|
fc->history_seek = 0;
|
||||||
|
|
||||||
@@ -508,7 +507,6 @@ MwWidget MwFileChooser(MwWidget handle, const char* title) {
|
|||||||
free(path);
|
free(path);
|
||||||
|
|
||||||
MwLLBeginStateChange(window->lowlevel);
|
MwLLBeginStateChange(window->lowlevel);
|
||||||
if(handle != NULL) MwLLDetach(window->lowlevel, &p);
|
|
||||||
MwLLMakePopup(window->lowlevel, handle == NULL ? NULL : handle->lowlevel);
|
MwLLMakePopup(window->lowlevel, handle == NULL ? NULL : handle->lowlevel);
|
||||||
MwLLEndStateChange(window->lowlevel);
|
MwLLEndStateChange(window->lowlevel);
|
||||||
|
|
||||||
|
|||||||
@@ -27,32 +27,32 @@ static void messagebox_close(MwWidget handle, void* user, void* call) {
|
|||||||
|
|
||||||
MwWidget MwMessageBox(MwWidget handle, const char* text, const char* title, unsigned int flag) {
|
MwWidget MwMessageBox(MwWidget handle, const char* text, const char* title, unsigned int flag) {
|
||||||
MwWidget window;
|
MwWidget window;
|
||||||
MwPoint p;
|
|
||||||
int w, h;
|
int w, h;
|
||||||
int left = 8;
|
int left = 8;
|
||||||
int th;
|
int th;
|
||||||
int x = 0;
|
int x = 0;
|
||||||
int wx;
|
int wx;
|
||||||
int wy;
|
int wy;
|
||||||
int ww = handle == NULL ? 0 : MwGetInteger(handle, MwNwidth);
|
|
||||||
int wh = handle == NULL ? 0 : MwGetInteger(handle, MwNheight);
|
|
||||||
MwSizeHints sh;
|
MwSizeHints sh;
|
||||||
|
|
||||||
w = 512;
|
w = 512;
|
||||||
h = 32 * 4;
|
h = 32 * 4;
|
||||||
|
|
||||||
wx = wy = 0;
|
if(handle == NULL) {
|
||||||
if(handle == NULL) wx = wy = MwDEFAULT;
|
wx = wy = MwDEFAULT;
|
||||||
|
} else {
|
||||||
|
wx = MwGetInteger(handle, MwNx) + (MwGetInteger(handle, MwNwidth) - w) / 2;
|
||||||
|
wy = MwGetInteger(handle, MwNy) + (MwGetInteger(handle, MwNheight) - h) / 2;
|
||||||
|
}
|
||||||
|
|
||||||
sh.min_width = sh.max_width = w;
|
sh.min_width = sh.max_width = w;
|
||||||
sh.min_height = sh.max_height = h;
|
sh.min_height = sh.max_height = h;
|
||||||
|
|
||||||
p.x = (ww - w) / 2;
|
window = MwVaCreateWidget(MwWindowClass, "messagebox", NULL, wx, wy, w, h,
|
||||||
p.y = (wh - h) / 2;
|
|
||||||
window = MwVaCreateWidget(MwWindowClass, "messagebox", handle, wx, wy, w, h,
|
|
||||||
MwNtitle, title,
|
MwNtitle, title,
|
||||||
MwNsizeHints, &sh,
|
MwNsizeHints, &sh,
|
||||||
NULL);
|
NULL);
|
||||||
|
if(handle != NULL) MwReparent(window, handle);
|
||||||
|
|
||||||
window->opaque = NULL;
|
window->opaque = NULL;
|
||||||
|
|
||||||
@@ -110,7 +110,6 @@ MwWidget MwMessageBox(MwWidget handle, const char* text, const char* title, unsi
|
|||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
MwLLBeginStateChange(window->lowlevel);
|
MwLLBeginStateChange(window->lowlevel);
|
||||||
if(handle != NULL) MwLLDetach(window->lowlevel, &p);
|
|
||||||
MwLLMakePopup(window->lowlevel, handle == NULL ? NULL : handle->lowlevel);
|
MwLLMakePopup(window->lowlevel, handle == NULL ? NULL : handle->lowlevel);
|
||||||
MwLLEndStateChange(window->lowlevel);
|
MwLLEndStateChange(window->lowlevel);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user