New bitmap method SetRGBConversionFunction which can be used to
[tangerine.git] / workbench / tools / WiMP.c
blobdc79a882481239fa1e1fe2608b6d717b8b1cde31
1 /*
2 Copyright © 1995-2006, The AROS Development Team. All rights reserved.
3 $Id$
5 WiMP -- Window manipulation program.
6 */
8 /******************************************************************************
10 NAME
12 WiMP
14 SYNOPSIS
17 LOCATION
19 Workbench:Tools
21 FUNCTION
23 Manipulates screens and windows
25 INPUTS
27 RESULT
29 NOTES
31 EXAMPLE
33 BUGS
35 SEE ALSO
37 INTERNALS
39 ******************************************************************************/
41 #define MUIMASTER_YES_INLINE_STDARG
43 #include <libraries/mui.h>
44 #include <libraries/gadtools.h>
45 #include <proto/muimaster.h>
46 #include <proto/intuition.h>
47 #include <proto/exec.h>
48 #include <proto/dos.h>
49 #include <proto/utility.h>
51 #include <stdlib.h>
52 #include <string.h>
53 #include <stdio.h>
56 static Object *app, *wnd, *list_gad;
58 static Object *close_gad, *front_gad, *back_gad, *origin_gad, *activate_gad, *zip_gad, *hide_gad, *show_gad;
59 static Object *update_gad, *rescue_gad, *showall_gad, *rethink_gad, *about_gad;
61 static Object *info_wnd, *page_gad;
63 static Object *info_scr_addr_gad, *info_scr_leftedge_gad, *info_scr_topedge_gad, *info_scr_width_gad, *info_scr_height_gad,
64 *info_scr_flags_gad, *info_scr_title_gad, *info_scr_deftitle_gad, *info_scr_firstwindow_gad;
67 static Object *info_win_addr_gad, *info_win_nextwin_gad, *info_win_leftedge_gad, *info_win_topedge_gad, *info_win_width_gad,
68 *info_win_height_gad, *info_win_minwidth_gad, *info_win_minheight_gad, *info_win_maxwidth_gad, *info_win_maxheight_gad,
69 *info_win_flags_gad, *info_win_idcmp_gad, *info_win_title_gad, *info_win_req_gad, *info_win_screen_gad,
70 *info_win_borderleft_gad, *info_win_bordertop_gad, *info_win_borderright_gad, *info_win_borderbottom_gad,
71 *info_win_parentwin_gad, *info_win_firstchild_gad, *info_win_parent_gad, *info_win_descendant_gad;
73 static ULONG lock;
76 static struct Hook close_hook, front_hook, back_hook, origin_hook, activate_hook, zip_hook, hide_hook, show_hook;
77 static struct Hook update_hook, rescue_hook, showall_hook, rethink_hook, about_hook;
78 static struct Hook display_hook, construct_hook, destruct_hook;
79 static struct Hook openinfo_hook, updateinfo_hook;
82 static const STRPTR ABOUT_TXT = "WiMP - The Window Manipulation Program\n\n"
83 "Copyright © 2000-2006 by The AROS Development Team";
84 static const STRPTR TITLE_TXT = "WiMP - The Window Manipulation Program";
85 static const STRPTR INFOTITLE_TXT = "WiMP - InfoWindow";
86 static const STRPTR CLOSESCREEN_TXT = "Do you really want to Close the selected Screen?";
87 static const STRPTR CLOSEWINDOW_TXT = "Do you really want to Close the selected Window?";
88 static const STRPTR YESNO_TXT = "Yes.|No!";
89 static const STRPTR CONTINUE_TXT = "Continue";
92 enum {
93 None_type,
94 Window_type,
95 Screen_type,
96 Max_type
100 struct ListEntry
102 LONG type;
103 APTR aptr;
104 TEXT address[20];
105 TEXT size[12];
106 TEXT pos[12];
107 TEXT status[4];
108 TEXT title[40];
111 static const char version[] = "$VER: WiMP 0.12 (04.05.2006) © AROS Dev Team";
113 /*********************************************************************************************/
115 static void Cleanup(CONST_STRPTR txt);
116 static LONG get_selected(struct Screen **scr, struct Window **win);
117 static void MakeGUI(void);
119 /*********************************************************************************************/
121 enum {
122 MN_ABOUT=1,
123 MN_QUIT,
124 MN_UPDATE,
125 MN_KILL,
126 MN_FRONT,
127 MN_BACK,
128 MN_ORIGIN,
129 MN_ACTIVATE,
130 MN_ZIP,
131 MN_HIDE,
132 MN_SHOW,
133 MN_INFO,
134 MN_RESCUE,
135 MN_SHOWALL,
136 MN_RETHINK,
139 static struct NewMenu nm[] =
141 {NM_TITLE, "Project"},
142 {NM_ITEM, "About...", NULL, 0, 0, (APTR)MN_ABOUT},
143 {NM_ITEM, NM_BARLABEL},
144 {NM_ITEM, "Quit", "Q", 0, 0, (APTR)MN_QUIT},
145 {NM_TITLE, "Window List"},
146 {NM_ITEM, "Update List", "U", 0, 0, (APTR)MN_UPDATE},
147 {NM_ITEM, NM_BARLABEL},
148 {NM_ITEM, "Kill", NULL, 0, 0, (APTR)MN_KILL},
149 {NM_ITEM, "To Front", NULL, 0, 0, (APTR)MN_FRONT},
150 {NM_ITEM, "To Back", NULL, 0, 0, (APTR)MN_BACK},
151 {NM_ITEM, "To Origin", NULL, 0, 0, (APTR)MN_ORIGIN},
152 {NM_ITEM, "Activate", NULL, 0, 0, (APTR)MN_ACTIVATE},
153 {NM_ITEM, "Zip", NULL, 0, 0, (APTR)MN_ZIP},
154 {NM_ITEM, "Hide", NULL, 0, 0, (APTR)MN_HIDE},
155 {NM_ITEM, "Show", NULL, 0, 0, (APTR)MN_SHOW},
156 {NM_ITEM, NM_BARLABEL},
157 {NM_ITEM, "Info", NULL, 0, 0, (APTR)MN_INFO},
158 {NM_TITLE, "Generic"},
159 {NM_ITEM, "Rescue All", NULL, 0, 0, (APTR)MN_RESCUE},
160 {NM_ITEM, "Show All", NULL, 0, 0, (APTR)MN_SHOWALL},
161 {NM_ITEM, "RethinkDisplay", NULL, 0, 0, (APTR)MN_RETHINK},
162 {NM_END}
165 /*********************************************************************************************/
167 static LONG get_selected(struct Screen **scr, struct Window **win)
169 *scr = NULL;
170 *win = NULL;
172 struct ListEntry *le;
173 DoMethod(list_gad, MUIM_List_GetEntry, MUIV_List_GetEntry_Active, (IPTR)&le);
175 if (le)
177 lock = LockIBase ( 0 );
178 *scr = IntuitionBase->FirstScreen;
179 UnlockIBase ( lock );
180 /* Traverse through all Screens */
181 while ( *scr )
183 if ((le->type == Screen_type) && (le->aptr == *scr))
185 return Screen_type;
188 /* Traverse through all Windows of current Screen */
189 *win = (*scr)->FirstWindow;
190 while ( *win )
192 if ((le->type == Window_type) && (le->aptr == *win))
194 return Window_type;
197 *win = (*win)->NextWindow;
199 *scr = (*scr)->NextScreen;
202 return None_type;
205 /*********************************************************************************************/
207 AROS_UFH3(void, display_func,
208 AROS_UFHA(struct Hook * , h, A0),
209 AROS_UFHA(char ** , array, A2),
210 AROS_UFHA(struct ListEntry *, msg, A1))
212 AROS_USERFUNC_INIT;
214 if (msg)
216 if (msg->type == Window_type)
218 array[0] = " \033bWindow";
220 else
222 array[0] = "\033b\033uScreen";
224 array[1] = msg->address;
225 array[2] = msg->size;
226 array[3] = msg->pos;
227 array[4] = msg->status;
228 array[5] = msg->title;
230 else
232 array[0] = "Type";
233 array[1] = "Address";
234 array[2] = "Size";
235 array[3] = "Position";
236 array[4] = "Status";
237 array[5] = "Title";
240 AROS_USERFUNC_EXIT
243 /*********************************************************************************************/
245 AROS_UFH3(APTR, construct_func,
246 AROS_UFHA(struct Hook * , h, A0),
247 AROS_UFHA(APTR , pool, A2),
248 AROS_UFHA(struct ListEntry *, msg, A1))
250 AROS_USERFUNC_INIT
252 struct ListEntry *new = AllocPooled(pool, sizeof(*msg));
253 if (new)
254 *new = *msg;
256 return new;
258 AROS_USERFUNC_EXIT
261 /*********************************************************************************************/
263 AROS_UFH3(void, destruct_func,
264 AROS_UFHA(struct Hook * , h, A0),
265 AROS_UFHA(APTR , pool, A2),
266 AROS_UFHA(struct ListEntry *, msg, A1))
268 AROS_USERFUNC_INIT
270 FreePooled(pool, msg, sizeof(*msg));
272 AROS_USERFUNC_EXIT
275 /*********************************************************************************************/
277 AROS_UFH3(void, update_func,
278 AROS_UFHA(struct Hook *, h, A0),
279 AROS_UFHA(Object * , object, A2),
280 AROS_UFHA(APTR , msg, A1))
282 AROS_USERFUNC_INIT;
284 struct Screen *scr;
285 struct Window *win;
286 struct ListEntry entry;
288 set(list_gad, MUIA_List_Quiet, TRUE);
289 DoMethod(list_gad, MUIM_List_Clear);
291 /* Get Intuition's first Screen */
292 lock = LockIBase ( 0 );
293 scr = IntuitionBase->FirstScreen;
294 UnlockIBase ( lock );
296 /* Traverse through all Screens */
297 while ( scr )
299 entry.type = Screen_type;
300 entry.aptr = scr;
301 sprintf(entry.address, "%p", scr);
302 sprintf(entry.size, "%d x %d", scr->Width, scr->Height);
303 sprintf(entry.pos, "%d x %d", scr->LeftEdge, scr->TopEdge);
304 entry.status[0] = '\0';
305 snprintf(entry.title, sizeof(entry.title) - 1, "%s", scr->Title ? scr->Title : "");
306 DoMethod(list_gad, MUIM_List_InsertSingle, &entry, MUIV_List_Insert_Bottom);
308 /* Traverse through all Windows of current Screen */
309 win = scr->FirstWindow;
310 while ( win )
312 entry.type = Window_type;
313 entry.aptr = win;
314 sprintf(entry.address, "%p", win);
315 sprintf(entry.size, "%d x %d", win->Width, win->Height);
316 sprintf(entry.pos, "%d x %d", win->LeftEdge, win->TopEdge);
317 sprintf(entry.status, "%c%c%c",
318 (IsWindowVisible(win) ? ' ' : 'H'),
319 (IS_CHILD(win) ? 'C' : ' '),
320 (HAS_CHILDREN(win) ? 'P' : ' '));
321 snprintf(entry.title, sizeof(entry.title) - 1, "%s", win->Title ? win->Title : "");
322 DoMethod(list_gad, MUIM_List_InsertSingle, &entry, MUIV_List_Insert_Bottom);
324 win = win->NextWindow;
326 scr = scr->NextScreen;
328 set(list_gad, MUIA_List_Quiet, FALSE);
330 AROS_USERFUNC_EXIT
333 /*********************************************************************************************/
335 AROS_UFH3(void, close_func,
336 AROS_UFHA(struct Hook *, h, A0),
337 AROS_UFHA(Object * , object, A2),
338 AROS_UFHA(APTR , msg, A1))
340 AROS_USERFUNC_INIT;
342 struct Screen *scr;
343 struct Window *win;
344 switch (get_selected(&scr, &win))
346 case Screen_type :
347 if (MUI_Request(app, wnd, 0, TITLE_TXT, YESNO_TXT, CLOSESCREEN_TXT))
349 CloseScreen(scr);
351 break;
352 case Window_type :
353 if (MUI_Request(app, wnd, 0, TITLE_TXT, YESNO_TXT, CLOSEWINDOW_TXT))
355 CloseWindow(win);
357 break;
360 CallHookPkt(&update_hook, 0, 0);
362 AROS_USERFUNC_EXIT
365 /*********************************************************************************************/
367 AROS_UFH3(void, front_func,
368 AROS_UFHA(struct Hook *, h, A0),
369 AROS_UFHA(Object * , object, A2),
370 AROS_UFHA(APTR , msg, A1))
372 AROS_USERFUNC_INIT;
374 struct Screen *scr;
375 struct Window *win;
376 switch (get_selected(&scr, &win))
378 case Screen_type:
379 ScreenToFront(scr);
380 break;
381 case Window_type:
382 WindowToFront(win);
383 break;
386 CallHookPkt(&update_hook, 0, 0);
388 AROS_USERFUNC_EXIT
391 /*********************************************************************************************/
393 AROS_UFH3(void, back_func,
394 AROS_UFHA(struct Hook *, h, A0),
395 AROS_UFHA(Object * , object, A2),
396 AROS_UFHA(APTR , msg, A1))
398 AROS_USERFUNC_INIT;
400 struct Screen *scr;
401 struct Window *win;
402 switch (get_selected(&scr, &win))
404 case Screen_type:
405 ScreenToBack(scr);
406 break;
407 case Window_type:
408 WindowToBack(win);
409 break;
412 CallHookPkt(&update_hook, 0, 0);
414 AROS_USERFUNC_EXIT
417 /*********************************************************************************************/
419 AROS_UFH3(void, origin_func,
420 AROS_UFHA(struct Hook *, h, A0),
421 AROS_UFHA(Object * , object, A2),
422 AROS_UFHA(APTR , msg, A1))
424 AROS_USERFUNC_INIT;
426 struct Screen *scr;
427 struct Window *win;
428 switch (get_selected(&scr, &win))
430 case Screen_type :
431 MoveScreen ( scr, -scr->LeftEdge, -scr->TopEdge );
432 break;
433 case Window_type :
434 MoveWindow ( win, -win->RelLeftEdge, -win->RelTopEdge );
435 break;
438 Delay(5);
439 CallHookPkt(&update_hook, 0, 0);
441 AROS_USERFUNC_EXIT
444 /*********************************************************************************************/
446 AROS_UFH3(void, activate_func,
447 AROS_UFHA(struct Hook *, h, A0),
448 AROS_UFHA(Object * , object, A2),
449 AROS_UFHA(APTR , msg, A1))
451 AROS_USERFUNC_INIT;
453 struct Screen *scr;
454 struct Window *win;
455 if (get_selected(&scr, &win) == Window_type )
457 ActivateWindow ( win );
460 CallHookPkt(&update_hook, 0, 0);
462 AROS_USERFUNC_EXIT
465 /*********************************************************************************************/
467 AROS_UFH3(void, hide_func,
468 AROS_UFHA(struct Hook *, h, A0),
469 AROS_UFHA(Object * , object, A2),
470 AROS_UFHA(APTR , msg, A1))
472 AROS_USERFUNC_INIT;
474 struct Screen *scr;
475 struct Window *win;
476 if (get_selected(&scr, &win) == Window_type)
478 if ((struct Window*)XGET(wnd, MUIA_Window_Window) != win) // You can't hide WiMP
480 HideWindow ( win );
484 Delay(5);
485 CallHookPkt(&update_hook, 0, 0);
487 AROS_USERFUNC_EXIT
490 /*********************************************************************************************/
492 AROS_UFH3(void, show_func,
493 AROS_UFHA(struct Hook *, h, A0),
494 AROS_UFHA(Object * , object, A2),
495 AROS_UFHA(APTR , msg, A1))
497 AROS_USERFUNC_INIT;
499 struct Screen *scr;
500 struct Window *win;
501 if (get_selected(&scr, &win) == Window_type)
503 ShowWindow ( win );
506 Delay(5);
507 CallHookPkt(&update_hook, 0, 0);
509 AROS_USERFUNC_EXIT
512 /*********************************************************************************************/
514 AROS_UFH3(void, zip_func,
515 AROS_UFHA(struct Hook *, h, A0),
516 AROS_UFHA(Object * , object, A2),
517 AROS_UFHA(APTR , msg, A1))
519 AROS_USERFUNC_INIT;
521 struct Screen *scr;
522 struct Window *win;
523 if (get_selected(&scr, &win) == Window_type)
525 ZipWindow ( win );
528 CallHookPkt(&update_hook, 0, 0);
530 AROS_USERFUNC_EXIT
533 /*********************************************************************************************/
535 AROS_UFH3(void, showall_func,
536 AROS_UFHA(struct Hook *, h, A0),
537 AROS_UFHA(Object * , object, A2),
538 AROS_UFHA(APTR , msg, A1))
540 AROS_USERFUNC_INIT;
542 struct Screen *scr;
543 struct Window *win;
545 /* Get Intuition's first Screen */
546 lock = LockIBase ( 0 );
547 scr = IntuitionBase->FirstScreen;
548 UnlockIBase ( lock );
550 /* Traverse through all Screens */
551 while ( scr )
553 win = scr->FirstWindow;
554 /* Traverse through all Windows of current Screen */
555 while ( win )
557 /* Show Window if hidden */
558 if ( IsWindowVisible ( win ) != TRUE )
560 ShowWindow ( win );
562 win = win->NextWindow;
564 scr = scr->NextScreen;
567 Delay(5);
568 CallHookPkt(&update_hook, 0, 0);
570 AROS_USERFUNC_EXIT
573 /*********************************************************************************************/
575 AROS_UFH3(void, rescue_func,
576 AROS_UFHA(struct Hook *, h, A0),
577 AROS_UFHA(Object * , object, A2),
578 AROS_UFHA(APTR , msg, A1))
580 AROS_USERFUNC_INIT;
582 struct Screen *scr;
583 struct Window *win;
584 WORD width, height;
586 /* Get Intuition's first Screen */
587 lock = LockIBase ( 0 );
588 scr = IntuitionBase->FirstScreen;
589 UnlockIBase ( lock );
591 /* Traverse through all Screens */
592 while ( scr )
594 win = scr->FirstWindow;
595 /* Traverse through all Windows of current Screen */
596 while ( win )
598 /* Move Window onto the Screen if outside */
599 if ( win->parent == NULL )
601 width = scr->Width;
602 height = scr->Height;
604 else
606 width = win->parent->Width;
607 height = win->parent->Height;
609 /* TODO: calculate reasonable values:
610 eg. this way only the Close Gadget my be visible :-( */
611 if ( win->RelLeftEdge < 0
612 || win->RelTopEdge <= -(win->BorderTop)
613 || win->RelLeftEdge > width
614 || win->RelTopEdge >= (height - win->BorderTop) )
616 MoveWindow ( win, - win->RelLeftEdge, - win->RelTopEdge );
618 win = win->NextWindow;
620 scr = scr->NextScreen;
623 Delay(5);
624 CallHookPkt(&update_hook, 0, 0);
626 AROS_USERFUNC_EXIT
629 /*********************************************************************************************/
631 AROS_UFH3(void, rethink_func,
632 AROS_UFHA(struct Hook *, h, A0),
633 AROS_UFHA(Object * , object, A2),
634 AROS_UFHA(APTR , msg, A1))
636 AROS_USERFUNC_INIT
638 RethinkDisplay();
639 CallHookPkt(&update_hook, 0, 0);
641 AROS_USERFUNC_EXIT
644 /*********************************************************************************************/
646 AROS_UFH3(void, about_func,
647 AROS_UFHA(struct Hook *, h, A0),
648 AROS_UFHA(Object * , object, A2),
649 AROS_UFHA(APTR , msg, A1))
651 AROS_USERFUNC_INIT
653 MUI_Request(app, wnd, 0, TITLE_TXT, CONTINUE_TXT, ABOUT_TXT);
655 AROS_USERFUNC_EXIT
658 /*********************************************************************************************/
660 AROS_UFH3(void, update_info_func,
661 AROS_UFHA(struct Hook *, h, A0),
662 AROS_UFHA(Object * , object, A2),
663 AROS_UFHA(APTR , msg, A1))
665 AROS_USERFUNC_INIT;
667 static TEXT buffer[50];
668 struct ListEntry *le;
669 struct Window *win;
670 struct Screen *scr;
672 DoMethod(list_gad, MUIM_List_GetEntry, MUIV_List_GetEntry_Active, (IPTR)&le);
673 if (le)
675 set(close_gad, MUIA_Disabled, FALSE);
676 set(front_gad, MUIA_Disabled, FALSE);
677 set(back_gad, MUIA_Disabled, FALSE);
678 set(origin_gad, MUIA_Disabled, FALSE);
679 set(activate_gad, MUIA_Disabled, FALSE);
680 set(zip_gad, MUIA_Disabled, FALSE);
681 set(hide_gad, MUIA_Disabled, FALSE);
682 set(show_gad, MUIA_Disabled, FALSE);
684 else
686 set(close_gad, MUIA_Disabled, TRUE);
687 set(front_gad, MUIA_Disabled, TRUE);
688 set(back_gad, MUIA_Disabled, TRUE);
689 set(origin_gad, MUIA_Disabled, TRUE);
690 set(activate_gad, MUIA_Disabled, TRUE);
691 set(zip_gad, MUIA_Disabled, TRUE);
692 set(hide_gad, MUIA_Disabled, TRUE);
693 set(show_gad, MUIA_Disabled, TRUE);
696 if (XGET(info_wnd, MUIA_Window_Open))
698 if (le)
700 switch (get_selected(&scr, &win))
702 case Screen_type:
704 scr = le->aptr;
705 set(page_gad, MUIA_Group_ActivePage, 0);
707 sprintf(buffer, "%p", scr);
708 set(info_scr_addr_gad, MUIA_Text_Contents, buffer);
710 sprintf(buffer, "%d", scr->LeftEdge);
711 set(info_scr_leftedge_gad, MUIA_Text_Contents, buffer);
713 sprintf(buffer, "%d", scr->TopEdge);
714 set(info_scr_topedge_gad, MUIA_Text_Contents, buffer);
716 sprintf(buffer, "%d", scr->Width);
717 set(info_scr_width_gad, MUIA_Text_Contents, buffer);
719 sprintf(buffer, "%d", scr->Height);
720 set(info_scr_height_gad, MUIA_Text_Contents, buffer);
722 sprintf(buffer, "0x%08x", scr->Flags);
723 set(info_scr_flags_gad, MUIA_Text_Contents, buffer);
725 set(info_scr_title_gad, MUIA_Text_Contents, scr->Title);
726 set(info_scr_deftitle_gad, MUIA_Text_Contents, scr->DefaultTitle);
728 sprintf(buffer, "%p", scr->FirstWindow);
729 set(info_scr_firstwindow_gad, MUIA_Text_Contents, buffer);
731 break;
733 case Window_type:
734 win = le->aptr;
735 set(page_gad, MUIA_Group_ActivePage, 1);
737 sprintf(buffer, "%p", win);
738 set(info_win_addr_gad, MUIA_Text_Contents, buffer);
740 sprintf(buffer, "%p", win->NextWindow);
741 set(info_win_nextwin_gad, MUIA_Text_Contents, buffer);
743 sprintf(buffer, "%d", win->LeftEdge);
744 set(info_win_leftedge_gad, MUIA_Text_Contents, buffer);
746 sprintf(buffer, "%d", win->TopEdge);
747 set(info_win_topedge_gad, MUIA_Text_Contents, buffer);
749 sprintf(buffer, "%d", win->Height);
750 set(info_win_height_gad, MUIA_Text_Contents, buffer);
752 sprintf(buffer, "%d", win->Width);
753 set(info_win_width_gad, MUIA_Text_Contents, buffer);
755 sprintf(buffer, "%d", win->MinWidth);
756 set(info_win_minwidth_gad, MUIA_Text_Contents, buffer);
758 sprintf(buffer, "%d", win->MinHeight);
759 set(info_win_minheight_gad, MUIA_Text_Contents, buffer);
761 sprintf(buffer, "%d", win->MaxWidth);
762 set(info_win_maxwidth_gad, MUIA_Text_Contents, buffer);
764 sprintf(buffer, "%d", win->MaxHeight);
765 set(info_win_maxheight_gad, MUIA_Text_Contents, buffer);
767 sprintf(buffer, "0x%08lx", win->Flags);
768 set(info_win_flags_gad, MUIA_Text_Contents, buffer);
770 sprintf(buffer, "0x%08lx", win->IDCMPFlags);
771 set(info_win_idcmp_gad, MUIA_Text_Contents, buffer);
773 set(info_win_title_gad, MUIA_Text_Contents, win->Title);
775 sprintf(buffer, "%d", win->ReqCount);
776 set(info_win_req_gad, MUIA_Text_Contents, buffer);
778 sprintf(buffer, "%p", win->WScreen);
779 set(info_win_screen_gad, MUIA_Text_Contents, buffer);
781 sprintf(buffer, "%d", win->BorderLeft);
782 set(info_win_borderleft_gad, MUIA_Text_Contents, buffer);
784 sprintf(buffer, "%d", win->BorderTop);
785 set(info_win_bordertop_gad, MUIA_Text_Contents, buffer);
787 sprintf(buffer, "%d", win->BorderRight);
788 set(info_win_borderright_gad, MUIA_Text_Contents, buffer);
790 sprintf(buffer, "%d", win->BorderBottom);
791 set(info_win_borderbottom_gad, MUIA_Text_Contents, buffer);
793 sprintf(buffer, "%p", win->parent);
794 set(info_win_parentwin_gad, MUIA_Text_Contents, buffer);
796 sprintf(buffer, "%p", win->firstchild);
797 set(info_win_firstchild_gad, MUIA_Text_Contents, buffer);
799 sprintf(buffer, "%p", win->Parent);
800 set(info_win_parent_gad, MUIA_Text_Contents, buffer);
802 sprintf(buffer, "%p", win->Descendant);
803 set(info_win_descendant_gad, MUIA_Text_Contents, buffer);
805 break;
806 default:
807 // selected screen/window doesn't exist anymore
808 CallHookPkt(&update_hook, 0, 0);
809 break;
812 else // window is open but no entry is selected
814 set(info_scr_addr_gad, MUIA_Text_Contents, NULL);
815 set(info_scr_leftedge_gad, MUIA_Text_Contents, NULL);
816 set(info_scr_topedge_gad, MUIA_Text_Contents, NULL);
817 set(info_scr_width_gad, MUIA_Text_Contents, NULL);
818 set(info_scr_height_gad, MUIA_Text_Contents, NULL);
819 set(info_scr_flags_gad, MUIA_Text_Contents, NULL);
820 set(info_scr_title_gad, MUIA_Text_Contents, NULL);
821 set(info_scr_deftitle_gad, MUIA_Text_Contents, NULL);
822 set(info_scr_firstwindow_gad, MUIA_Text_Contents, NULL);
823 set(info_win_addr_gad, MUIA_Text_Contents, NULL);
824 set(info_win_nextwin_gad, MUIA_Text_Contents, NULL);
825 set(info_win_leftedge_gad, MUIA_Text_Contents, NULL);
826 set(info_win_topedge_gad, MUIA_Text_Contents, NULL);
827 set(info_win_height_gad, MUIA_Text_Contents, NULL);
828 set(info_win_width_gad, MUIA_Text_Contents, NULL);
829 set(info_win_minwidth_gad, MUIA_Text_Contents, NULL);
830 set(info_win_minheight_gad, MUIA_Text_Contents, NULL);
831 set(info_win_maxwidth_gad, MUIA_Text_Contents, NULL);
832 set(info_win_maxheight_gad, MUIA_Text_Contents, NULL);
833 set(info_win_flags_gad, MUIA_Text_Contents, NULL);
834 set(info_win_idcmp_gad, MUIA_Text_Contents, NULL);
835 set(info_win_title_gad, MUIA_Text_Contents, NULL);
836 set(info_win_req_gad, MUIA_Text_Contents, NULL);
837 set(info_win_screen_gad, MUIA_Text_Contents, NULL);
838 set(info_win_borderleft_gad, MUIA_Text_Contents, NULL);
839 set(info_win_bordertop_gad, MUIA_Text_Contents, NULL);
840 set(info_win_borderright_gad, MUIA_Text_Contents, NULL);
841 set(info_win_borderbottom_gad, MUIA_Text_Contents, NULL);
842 set(info_win_parentwin_gad, MUIA_Text_Contents, NULL);
843 set(info_win_firstchild_gad, MUIA_Text_Contents, NULL);
844 set(info_win_parent_gad, MUIA_Text_Contents, NULL);
845 set(info_win_descendant_gad, MUIA_Text_Contents, NULL);
849 AROS_USERFUNC_EXIT
852 /*********************************************************************************************/
854 AROS_UFH3(void, openinfo_func,
855 AROS_UFHA(struct Hook *, h, A0),
856 AROS_UFHA(Object * , object, A2),
857 AROS_UFHA(APTR , msg, A1))
859 AROS_USERFUNC_INIT
861 set(info_wnd, MUIA_Window_Open, TRUE);
862 CallHookPkt(&updateinfo_hook, 0, 0);
863 AROS_USERFUNC_EXIT
866 /*********************************************************************************************/
868 static void MakeGUI(void)
870 Object *menu = MUI_MakeObject(MUIO_MenustripNM, &nm, 0);
872 display_hook.h_Entry = (HOOKFUNC)display_func;
873 construct_hook.h_Entry = (HOOKFUNC)construct_func;
874 destruct_hook.h_Entry = (HOOKFUNC)destruct_func;
876 close_hook.h_Entry = (HOOKFUNC)close_func;
877 front_hook.h_Entry = (HOOKFUNC)front_func;
878 back_hook.h_Entry = (HOOKFUNC)back_func;
879 origin_hook.h_Entry = (HOOKFUNC)origin_func;
880 activate_hook.h_Entry = (HOOKFUNC)activate_func;
881 zip_hook.h_Entry = (HOOKFUNC)zip_func;
882 hide_hook.h_Entry = (HOOKFUNC)hide_func;
883 show_hook.h_Entry = (HOOKFUNC)show_func;
885 update_hook.h_Entry = (HOOKFUNC)update_func;
886 rescue_hook.h_Entry = (HOOKFUNC)rescue_func;
887 showall_hook.h_Entry = (HOOKFUNC)showall_func;
888 rethink_hook.h_Entry = (HOOKFUNC)rethink_func;
889 about_hook.h_Entry = (HOOKFUNC)about_func;
891 openinfo_hook.h_Entry = (HOOKFUNC)openinfo_func;
892 updateinfo_hook.h_Entry = (HOOKFUNC)update_info_func;
894 app = ApplicationObject,
895 MUIA_Application_Title, (IPTR)"WiMP",
896 MUIA_Application_Version, (IPTR)version,
897 MUIA_Application_Copyright, (IPTR)"Copyright © 1995-2006, The AROS Development Team",
898 MUIA_Application_Author, (IPTR)"The AROS Development Team",
899 MUIA_Application_Description, (IPTR)"Window Manipulator",
900 MUIA_Application_Base, (IPTR)"WIMP",
901 MUIA_Application_SingleTask, TRUE,
902 MUIA_Application_Menustrip, (IPTR)menu,
903 SubWindow, (IPTR)(wnd = WindowObject,
904 MUIA_Window_Title, (IPTR)TITLE_TXT,
905 MUIA_Window_ID, MAKE_ID('W', 'I', 'M', 'P'),
906 WindowContents, (IPTR)(VGroup,
907 Child, (IPTR)(VGroup,
908 GroupFrameT("Screen/Window List"),
909 Child, (IPTR)(ListviewObject,
910 MUIA_Listview_List, (IPTR)(list_gad = ListObject,
911 InputListFrame,
912 MUIA_List_Format, (IPTR)"BAR,BAR,P=\033c BAR,P=\033c BAR,BAR,BAR",
913 MUIA_List_ConstructHook, (IPTR)&construct_hook,
914 MUIA_List_DestructHook, (IPTR)&destruct_hook,
915 MUIA_List_DisplayHook, (IPTR)&display_hook,
916 MUIA_List_Title, TRUE,
917 MUIA_CycleChain, 1,
918 End),
919 End),
920 Child, (IPTR)(HGroup,
921 Child, (IPTR)(close_gad = SimpleButton("\033iKill")),
922 Child, (IPTR)(front_gad = SimpleButton("To _Front")),
923 Child, (IPTR)(back_gad = SimpleButton("To _Back")),
924 Child, (IPTR)(origin_gad = SimpleButton("Move to _Origin")),
925 Child, (IPTR)(activate_gad = SimpleButton("_Activate")),
926 Child, (IPTR)(zip_gad = SimpleButton("_Zip")),
927 Child, (IPTR)(hide_gad = SimpleButton("_Hide")),
928 Child, (IPTR)(show_gad = SimpleButton("_Show")),
929 End),
930 Child, (IPTR)(HGroup,
931 Child, (IPTR)(update_gad = SimpleButton("_Update List")),
932 Child, (IPTR)(rescue_gad = SimpleButton("_Rescue all Windows")),
933 Child, (IPTR)(showall_gad = SimpleButton("Show all Windows")),
934 Child, (IPTR)(rethink_gad = SimpleButton("Rethink Display")),
935 Child, (IPTR)(about_gad = SimpleButton("About")),
936 End),
937 End),
938 End),
939 End), // wnd
940 SubWindow, (IPTR)(info_wnd = WindowObject,
941 MUIA_Window_Title, (IPTR)INFOTITLE_TXT,
942 MUIA_Window_ID, MAKE_ID('W', 'I', 'N', 'F'),
943 WindowContents, (IPTR)(page_gad = PageGroup,
944 Child, (IPTR)(HGroup,
945 Child, (IPTR)(ColGroup(2),
946 GroupFrameT("Screen"),
948 Child, (IPTR)Label("Address"),
949 Child, (IPTR)(info_scr_addr_gad = TextObject,
950 TextFrame,
951 MUIA_Text_Contents, (IPTR)"WWWWWWWWWWWWWWWWWWWWWWWWWWWWWW",
952 MUIA_Text_SetMin, TRUE,
953 End),
954 Child, (IPTR)Label("LeftEdge"),
955 Child, (IPTR)(info_scr_leftedge_gad = TextObject, TextFrame, End),
956 Child, (IPTR)Label("TopEdge"),
957 Child, (IPTR)(info_scr_topedge_gad = TextObject, TextFrame, End),
958 Child, (IPTR)Label("Width"),
959 Child, (IPTR)(info_scr_width_gad = TextObject, TextFrame, End),
960 Child, (IPTR)Label("Height"),
961 Child, (IPTR)(info_scr_height_gad = TextObject, TextFrame, End),
962 Child, (IPTR)Label("Flags"),
963 Child, (IPTR)(info_scr_flags_gad = TextObject, TextFrame, End),
964 Child, (IPTR)Label("Title"),
965 Child, (IPTR)(info_scr_title_gad = TextObject, TextFrame, End),
966 Child, (IPTR)Label("DefaultTitle"),
967 Child, (IPTR)(info_scr_deftitle_gad = TextObject, TextFrame, End),
968 Child, (IPTR)Label("FirstWindow"),
969 Child, (IPTR)(info_scr_firstwindow_gad = TextObject, TextFrame, End),
970 End),
971 End),
972 Child, (IPTR)(HGroup,
973 Child, (IPTR)(ColGroup(2),
974 GroupFrameT("Window"),
975 Child, (IPTR)Label("Address"),
976 Child, (IPTR)(info_win_addr_gad = TextObject,
977 TextFrame,
978 MUIA_Text_Contents, (IPTR)"WWWWWWWWWWWWWWWWWWWWWWWWWWWWWW",
979 MUIA_Text_SetMin, TRUE,
980 End),
981 Child, (IPTR)Label("NextWindow"),
982 Child, (IPTR)(info_win_nextwin_gad = TextObject, TextFrame, End),
983 Child, (IPTR)Label("LeftEdge"),
984 Child, (IPTR)(info_win_leftedge_gad = TextObject, TextFrame, End),
985 Child, (IPTR)Label("TopEdge"),
986 Child, (IPTR)(info_win_topedge_gad = TextObject, TextFrame, End),
987 Child, (IPTR)Label("Width"),
988 Child, (IPTR)(info_win_width_gad = TextObject, TextFrame, End),
989 Child, (IPTR)Label("Height"),
990 Child, (IPTR)(info_win_height_gad = TextObject, TextFrame, End),
991 Child, (IPTR)Label("MinWidth"),
992 Child, (IPTR)(info_win_minwidth_gad = TextObject, TextFrame, End),
993 Child, (IPTR)Label("MinHeight"),
994 Child, (IPTR)(info_win_minheight_gad = TextObject, TextFrame, End),
995 Child, (IPTR)Label("MaxWidth"),
996 Child, (IPTR)(info_win_maxwidth_gad = TextObject, TextFrame, End),
997 Child, (IPTR)Label("MaxHeight"),
998 Child, (IPTR)(info_win_maxheight_gad = TextObject, TextFrame, End),
999 Child, (IPTR)Label("Flags"),
1000 Child, (IPTR)(info_win_flags_gad = TextObject, TextFrame, End),
1001 Child, (IPTR)Label("IDCMPFlags"),
1002 Child, (IPTR)(info_win_idcmp_gad = TextObject, TextFrame, End),
1003 Child, (IPTR)Label("Title"),
1004 Child, (IPTR)(info_win_title_gad = TextObject, TextFrame, End),
1005 Child, (IPTR)Label("ReqCount"),
1006 Child, (IPTR)(info_win_req_gad = TextObject, TextFrame, End),
1007 Child, (IPTR)Label("WScreen"),
1008 Child, (IPTR)(info_win_screen_gad = TextObject, TextFrame, End),
1009 Child, (IPTR)Label("BorderLeft"),
1010 Child, (IPTR)(info_win_borderleft_gad = TextObject, TextFrame, End),
1011 Child, (IPTR)Label("BorderTop"),
1012 Child, (IPTR)(info_win_bordertop_gad = TextObject, TextFrame, End),
1013 Child, (IPTR)Label("BorderRight"),
1014 Child, (IPTR)(info_win_borderright_gad = TextObject, TextFrame, End),
1015 Child, (IPTR)Label("BoderBottom"),
1016 Child, (IPTR)(info_win_borderbottom_gad = TextObject, TextFrame, End),
1017 Child, (IPTR)Label("Parent Window"),
1018 Child, (IPTR)(info_win_parentwin_gad = TextObject, TextFrame, End),
1019 Child, (IPTR)Label("First Child"),
1020 Child, (IPTR)(info_win_firstchild_gad = TextObject, TextFrame, End),
1021 Child, (IPTR)Label("Parent"),
1022 Child, (IPTR)(info_win_parent_gad = TextObject, TextFrame, End),
1023 Child, (IPTR)Label("Descendant"),
1024 Child, (IPTR)(info_win_descendant_gad = TextObject, TextFrame, End),
1025 End),
1026 End),
1027 End),
1028 End), // infownd
1029 End; // app
1031 if (! app)
1032 Cleanup(NULL); // Probably double start
1034 DoMethod(wnd, MUIM_Notify, MUIA_Window_CloseRequest, TRUE,
1035 app, 2, MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit);
1037 DoMethod(info_wnd, MUIM_Notify, MUIA_Window_CloseRequest, TRUE,
1038 info_wnd, 3, MUIM_Set, MUIA_Window_Open, FALSE);
1040 DoMethod(list_gad, MUIM_Notify, MUIA_List_Active, MUIV_EveryTime,
1041 (IPTR)app, 2, MUIM_CallHook, (IPTR)&updateinfo_hook);
1043 DoMethod(list_gad, MUIM_Notify, MUIA_Listview_DoubleClick, TRUE,
1044 (IPTR)app, 2, MUIM_CallHook, (IPTR)&openinfo_hook);
1047 // menu bar
1048 DoMethod(app, MUIM_Notify, MUIA_Application_MenuAction, MN_QUIT,
1049 (IPTR)app, 2, MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit);
1051 DoMethod(app, MUIM_Notify, MUIA_Application_MenuAction, MN_ABOUT,
1052 (IPTR)app, 2, MUIM_CallHook, (IPTR)&about_hook);
1054 DoMethod(app, MUIM_Notify, MUIA_Application_MenuAction, MN_UPDATE,
1055 (IPTR)app, 2, MUIM_CallHook, (IPTR)&update_hook);
1057 DoMethod(app, MUIM_Notify, MUIA_Application_MenuAction, MN_KILL,
1058 (IPTR)app, 2, MUIM_CallHook, (IPTR)&close_hook);
1060 DoMethod(app, MUIM_Notify, MUIA_Application_MenuAction, MN_FRONT,
1061 (IPTR)app, 2, MUIM_CallHook, (IPTR)&front_hook);
1063 DoMethod(app, MUIM_Notify, MUIA_Application_MenuAction, MN_BACK,
1064 (IPTR)app, 2, MUIM_CallHook, (IPTR)&back_hook);
1066 DoMethod(app, MUIM_Notify, MUIA_Application_MenuAction, MN_ORIGIN,
1067 (IPTR)app, 2, MUIM_CallHook, (IPTR)&origin_hook);
1069 DoMethod(app, MUIM_Notify, MUIA_Application_MenuAction, MN_ACTIVATE,
1070 (IPTR)app, 2, MUIM_CallHook, (IPTR)&activate_hook);
1072 DoMethod(app, MUIM_Notify, MUIA_Application_MenuAction, MN_ZIP,
1073 (IPTR)app, 2, MUIM_CallHook, (IPTR)&zip_hook);
1075 DoMethod(app, MUIM_Notify, MUIA_Application_MenuAction, MN_HIDE,
1076 (IPTR)app, 2, MUIM_CallHook, (IPTR)&hide_hook);
1078 DoMethod(app, MUIM_Notify, MUIA_Application_MenuAction, MN_SHOW,
1079 (IPTR)app, 2, MUIM_CallHook, (IPTR)&show_hook);
1081 DoMethod(app, MUIM_Notify, MUIA_Application_MenuAction, MN_INFO,
1082 (IPTR)app, 2, MUIM_CallHook, (IPTR)&openinfo_hook);
1084 DoMethod(app, MUIM_Notify, MUIA_Application_MenuAction, MN_RESCUE,
1085 (IPTR)app, 2, MUIM_CallHook, (IPTR)&rescue_hook);
1087 DoMethod(app, MUIM_Notify, MUIA_Application_MenuAction, MN_SHOWALL,
1088 (IPTR)app, 2, MUIM_CallHook, (IPTR)&showall_hook);
1090 DoMethod(app, MUIM_Notify, MUIA_Application_MenuAction, MN_RETHINK,
1091 (IPTR)app, 2, MUIM_CallHook, (IPTR)&rethink_hook);
1094 // buttons first row
1095 DoMethod(close_gad, MUIM_Notify, MUIA_Pressed, FALSE,
1096 (IPTR)app, 2, MUIM_CallHook, (IPTR)&close_hook);
1098 DoMethod(front_gad, MUIM_Notify, MUIA_Pressed, FALSE,
1099 (IPTR)app, 2, MUIM_CallHook, (IPTR)&front_hook);
1101 DoMethod(back_gad, MUIM_Notify, MUIA_Pressed, FALSE,
1102 (IPTR)app, 2, MUIM_CallHook, (IPTR)&back_hook);
1104 DoMethod(origin_gad, MUIM_Notify, MUIA_Pressed, FALSE,
1105 (IPTR)app, 2, MUIM_CallHook, (IPTR)&origin_hook);
1107 DoMethod(activate_gad, MUIM_Notify, MUIA_Pressed, FALSE,
1108 (IPTR)app, 2, MUIM_CallHook, (IPTR)&activate_hook);
1110 DoMethod(zip_gad, MUIM_Notify, MUIA_Pressed, FALSE,
1111 (IPTR)app, 2, MUIM_CallHook, (IPTR)&zip_hook);
1113 DoMethod(hide_gad, MUIM_Notify, MUIA_Pressed, FALSE,
1114 (IPTR)app, 2, MUIM_CallHook, (IPTR)&hide_hook);
1116 DoMethod(show_gad, MUIM_Notify, MUIA_Pressed, FALSE,
1117 (IPTR)app, 2, MUIM_CallHook, (IPTR)&show_hook);
1120 // buttons second row
1121 DoMethod(update_gad, MUIM_Notify, MUIA_Pressed, FALSE,
1122 (IPTR)app, 2, MUIM_CallHook, (IPTR)&update_hook);
1124 DoMethod(rescue_gad, MUIM_Notify, MUIA_Pressed, FALSE,
1125 (IPTR)app, 2, MUIM_CallHook, (IPTR)&rescue_hook);
1127 DoMethod(showall_gad, MUIM_Notify, MUIA_Pressed, FALSE,
1128 (IPTR)app, 2, MUIM_CallHook, (IPTR)&showall_hook);
1130 DoMethod(rethink_gad, MUIM_Notify, MUIA_Pressed, FALSE,
1131 (IPTR)app, 2, MUIM_CallHook, (IPTR)&rethink_hook);
1133 DoMethod(about_gad, MUIM_Notify, MUIA_Pressed, FALSE,
1134 (IPTR)app, 2, MUIM_CallHook, (IPTR)&about_hook);
1136 set(wnd, MUIA_Window_Open, TRUE);
1137 CallHookPkt(&update_hook, 0, 0);
1138 CallHookPkt(&updateinfo_hook, 0, 0);
1139 DoMethod(app, MUIM_Application_Execute);
1142 /*********************************************************************************************/
1144 static void Cleanup(CONST_STRPTR txt)
1146 MUI_DisposeObject(app);
1147 if (txt)
1149 MUI_Request(app, wnd, 0, TITLE_TXT, "OK", txt);
1150 exit(RETURN_ERROR);
1152 exit(RETURN_OK);
1155 /*********************************************************************************************/
1157 int main(int argc, char **argv)
1159 MakeGUI();
1160 Cleanup(NULL);
1161 return RETURN_OK;