2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
5 WiMP -- Window manipulation program.
8 /******************************************************************************
23 Manipulates screens and windows
39 ******************************************************************************/
41 #define MUIMASTER_YES_INLINE_STDARG
43 #include <libraries/mui.h>
44 #include <libraries/gadtools.h>
46 #include <proto/alib.h>
47 #include <proto/muimaster.h>
48 #include <proto/intuition.h>
49 #include <proto/exec.h>
50 #include <proto/dos.h>
51 #include <proto/utility.h>
58 static Object
*app
, *wnd
, *list_gad
;
60 static Object
*close_gad
, *front_gad
, *back_gad
, *origin_gad
, *activate_gad
, *zip_gad
, *hide_gad
, *show_gad
;
61 static Object
*update_gad
, *rescue_gad
, *showall_gad
, *rethink_gad
, *about_gad
;
63 static Object
*info_wnd
, *page_gad
;
65 static Object
*info_scr_addr_gad
, *info_scr_leftedge_gad
, *info_scr_topedge_gad
, *info_scr_width_gad
, *info_scr_height_gad
,
66 *info_scr_flags_gad
, *info_scr_title_gad
, *info_scr_deftitle_gad
, *info_scr_firstwindow_gad
;
69 static Object
*info_win_addr_gad
, *info_win_nextwin_gad
, *info_win_leftedge_gad
, *info_win_topedge_gad
, *info_win_width_gad
,
70 *info_win_height_gad
, *info_win_minwidth_gad
, *info_win_minheight_gad
, *info_win_maxwidth_gad
, *info_win_maxheight_gad
,
71 *info_win_flags_gad
, *info_win_idcmp_gad
, *info_win_title_gad
, *info_win_req_gad
, *info_win_screen_gad
,
72 *info_win_borderleft_gad
, *info_win_bordertop_gad
, *info_win_borderright_gad
, *info_win_borderbottom_gad
,
73 *info_win_parentwin_gad
, *info_win_firstchild_gad
, *info_win_parent_gad
, *info_win_descendant_gad
;
78 static struct Hook close_hook
, front_hook
, back_hook
, origin_hook
, activate_hook
, zip_hook
, hide_hook
, show_hook
;
79 static struct Hook update_hook
, rescue_hook
, showall_hook
, rethink_hook
, about_hook
;
80 static struct Hook display_hook
, construct_hook
, destruct_hook
;
81 static struct Hook openinfo_hook
, updateinfo_hook
;
84 static const STRPTR ABOUT_TXT
= "WiMP - The Window Manipulation Program\n\n"
85 "Copyright © 2000-2009 by The AROS Development Team";
86 static const STRPTR TITLE_TXT
= "WiMP - The Window Manipulation Program";
87 static const STRPTR INFOTITLE_TXT
= "WiMP - InfoWindow";
88 static const STRPTR CLOSESCREEN_TXT
= "Do you really want to Close the selected Screen?";
89 static const STRPTR CLOSEWINDOW_TXT
= "Do you really want to Close the selected Window?";
90 static const STRPTR YESNO_TXT
= "Yes.|No!";
91 static const STRPTR CONTINUE_TXT
= "Continue";
113 static const char version
[] = "$VER: WiMP 0.13 (06.01.2009) © AROS Dev Team";
115 /*********************************************************************************************/
117 static void Cleanup(CONST_STRPTR txt
);
118 static LONG
get_selected(struct Screen
**scr
, struct Window
**win
);
119 static void MakeGUI(void);
121 /*********************************************************************************************/
141 static struct NewMenu nm
[] =
143 {NM_TITLE
, "Project"},
144 {NM_ITEM
, "About...", NULL
, 0, 0, (APTR
)MN_ABOUT
},
145 {NM_ITEM
, NM_BARLABEL
},
146 {NM_ITEM
, "Quit", "Q", 0, 0, (APTR
)MN_QUIT
},
147 {NM_TITLE
, "Window List"},
148 {NM_ITEM
, "Update List", "U", 0, 0, (APTR
)MN_UPDATE
},
149 {NM_ITEM
, NM_BARLABEL
},
150 {NM_ITEM
, "Kill", NULL
, 0, 0, (APTR
)MN_KILL
},
151 {NM_ITEM
, "To Front", NULL
, 0, 0, (APTR
)MN_FRONT
},
152 {NM_ITEM
, "To Back", NULL
, 0, 0, (APTR
)MN_BACK
},
153 {NM_ITEM
, "To Origin", NULL
, 0, 0, (APTR
)MN_ORIGIN
},
154 {NM_ITEM
, "Activate", NULL
, 0, 0, (APTR
)MN_ACTIVATE
},
155 {NM_ITEM
, "Zip", NULL
, 0, 0, (APTR
)MN_ZIP
},
156 {NM_ITEM
, "Hide", NULL
, 0, 0, (APTR
)MN_HIDE
},
157 {NM_ITEM
, "Show", NULL
, 0, 0, (APTR
)MN_SHOW
},
158 {NM_ITEM
, NM_BARLABEL
},
159 {NM_ITEM
, "Info", NULL
, 0, 0, (APTR
)MN_INFO
},
160 {NM_TITLE
, "Generic"},
161 {NM_ITEM
, "Rescue All", NULL
, 0, 0, (APTR
)MN_RESCUE
},
162 {NM_ITEM
, "Show All", NULL
, 0, 0, (APTR
)MN_SHOWALL
},
163 {NM_ITEM
, "RethinkDisplay", NULL
, 0, 0, (APTR
)MN_RETHINK
},
167 /*********************************************************************************************/
169 static LONG
get_selected(struct Screen
**scr
, struct Window
**win
)
174 struct ListEntry
*le
;
175 DoMethod(list_gad
, MUIM_List_GetEntry
, MUIV_List_GetEntry_Active
, (IPTR
)&le
);
179 lock
= LockIBase ( 0 );
180 *scr
= IntuitionBase
->FirstScreen
;
181 UnlockIBase ( lock
);
182 /* Traverse through all Screens */
185 if ((le
->type
== Screen_type
) && (le
->aptr
== *scr
))
190 /* Traverse through all Windows of current Screen */
191 *win
= (*scr
)->FirstWindow
;
194 if ((le
->type
== Window_type
) && (le
->aptr
== *win
))
199 *win
= (*win
)->NextWindow
;
201 *scr
= (*scr
)->NextScreen
;
207 /*********************************************************************************************/
209 AROS_UFH3(void, display_func
,
210 AROS_UFHA(struct Hook
* , h
, A0
),
211 AROS_UFHA(char ** , array
, A2
),
212 AROS_UFHA(struct ListEntry
*, msg
, A1
))
218 if (msg
->type
== Window_type
)
220 array
[0] = " \033bWindow";
224 array
[0] = "\033b\033uScreen";
226 array
[1] = msg
->address
;
227 array
[2] = msg
->size
;
229 array
[4] = msg
->status
;
230 array
[5] = msg
->title
;
235 array
[1] = "Address";
237 array
[3] = "Position";
245 /*********************************************************************************************/
247 AROS_UFH3(APTR
, construct_func
,
248 AROS_UFHA(struct Hook
* , h
, A0
),
249 AROS_UFHA(APTR
, pool
, A2
),
250 AROS_UFHA(struct ListEntry
*, msg
, A1
))
254 struct ListEntry
*new = AllocPooled(pool
, sizeof(*msg
));
263 /*********************************************************************************************/
265 AROS_UFH3(void, destruct_func
,
266 AROS_UFHA(struct Hook
* , h
, A0
),
267 AROS_UFHA(APTR
, pool
, A2
),
268 AROS_UFHA(struct ListEntry
*, msg
, A1
))
272 FreePooled(pool
, msg
, sizeof(*msg
));
277 /*********************************************************************************************/
279 AROS_UFH3(void, update_func
,
280 AROS_UFHA(struct Hook
*, h
, A0
),
281 AROS_UFHA(Object
* , object
, A2
),
282 AROS_UFHA(APTR
, msg
, A1
))
288 struct ListEntry entry
;
290 set(list_gad
, MUIA_List_Quiet
, TRUE
);
291 DoMethod(list_gad
, MUIM_List_Clear
);
293 /* Get Intuition's first Screen */
294 lock
= LockIBase ( 0 );
295 scr
= IntuitionBase
->FirstScreen
;
296 UnlockIBase ( lock
);
298 /* Traverse through all Screens */
301 entry
.type
= Screen_type
;
303 sprintf(entry
.address
, "%p", scr
);
304 sprintf(entry
.size
, "%d x %d", scr
->Width
, scr
->Height
);
305 sprintf(entry
.pos
, "%d x %d", scr
->LeftEdge
, scr
->TopEdge
);
306 entry
.status
[0] = '\0';
307 snprintf(entry
.title
, sizeof(entry
.title
) - 1, "%s", scr
->Title
? (char *)scr
->Title
: "");
308 DoMethod(list_gad
, MUIM_List_InsertSingle
, &entry
, MUIV_List_Insert_Bottom
);
310 /* Traverse through all Windows of current Screen */
311 win
= scr
->FirstWindow
;
314 entry
.type
= Window_type
;
316 sprintf(entry
.address
, "%p", win
);
317 sprintf(entry
.size
, "%d x %d", win
->Width
, win
->Height
);
318 sprintf(entry
.pos
, "%d x %d", win
->LeftEdge
, win
->TopEdge
);
319 sprintf(entry
.status
, "%c%c%c",
320 (IsWindowVisible(win
) ? ' ' : 'H'),
321 (IS_CHILD(win
) ? 'C' : ' '),
322 (HAS_CHILDREN(win
) ? 'P' : ' '));
323 snprintf(entry
.title
, sizeof(entry
.title
) - 1, "%s", win
->Title
? (char *)win
->Title
: "");
324 DoMethod(list_gad
, MUIM_List_InsertSingle
, &entry
, MUIV_List_Insert_Bottom
);
326 win
= win
->NextWindow
;
328 scr
= scr
->NextScreen
;
330 set(list_gad
, MUIA_List_Quiet
, FALSE
);
335 /*********************************************************************************************/
337 AROS_UFH3(void, close_func
,
338 AROS_UFHA(struct Hook
*, h
, A0
),
339 AROS_UFHA(Object
* , object
, A2
),
340 AROS_UFHA(APTR
, msg
, A1
))
346 switch (get_selected(&scr
, &win
))
349 if (MUI_Request(app
, wnd
, 0, TITLE_TXT
, YESNO_TXT
, CLOSESCREEN_TXT
))
355 if (MUI_Request(app
, wnd
, 0, TITLE_TXT
, YESNO_TXT
, CLOSEWINDOW_TXT
))
362 CallHookPkt(&update_hook
, 0, 0);
367 /*********************************************************************************************/
369 AROS_UFH3(void, front_func
,
370 AROS_UFHA(struct Hook
*, h
, A0
),
371 AROS_UFHA(Object
* , object
, A2
),
372 AROS_UFHA(APTR
, msg
, A1
))
378 switch (get_selected(&scr
, &win
))
388 CallHookPkt(&update_hook
, 0, 0);
393 /*********************************************************************************************/
395 AROS_UFH3(void, back_func
,
396 AROS_UFHA(struct Hook
*, h
, A0
),
397 AROS_UFHA(Object
* , object
, A2
),
398 AROS_UFHA(APTR
, msg
, A1
))
404 switch (get_selected(&scr
, &win
))
414 CallHookPkt(&update_hook
, 0, 0);
419 /*********************************************************************************************/
421 AROS_UFH3(void, origin_func
,
422 AROS_UFHA(struct Hook
*, h
, A0
),
423 AROS_UFHA(Object
* , object
, A2
),
424 AROS_UFHA(APTR
, msg
, A1
))
430 switch (get_selected(&scr
, &win
))
433 MoveScreen ( scr
, -scr
->LeftEdge
, -scr
->TopEdge
);
436 MoveWindow ( win
, -win
->RelLeftEdge
, -win
->RelTopEdge
);
441 CallHookPkt(&update_hook
, 0, 0);
446 /*********************************************************************************************/
448 AROS_UFH3(void, activate_func
,
449 AROS_UFHA(struct Hook
*, h
, A0
),
450 AROS_UFHA(Object
* , object
, A2
),
451 AROS_UFHA(APTR
, msg
, A1
))
457 if (get_selected(&scr
, &win
) == Window_type
)
459 ActivateWindow ( win
);
462 CallHookPkt(&update_hook
, 0, 0);
467 /*********************************************************************************************/
469 AROS_UFH3(void, hide_func
,
470 AROS_UFHA(struct Hook
*, h
, A0
),
471 AROS_UFHA(Object
* , object
, A2
),
472 AROS_UFHA(APTR
, msg
, A1
))
478 if (get_selected(&scr
, &win
) == Window_type
)
480 if ((struct Window
*)XGET(wnd
, MUIA_Window_Window
) != win
) // You can't hide WiMP
487 CallHookPkt(&update_hook
, 0, 0);
492 /*********************************************************************************************/
494 AROS_UFH3(void, show_func
,
495 AROS_UFHA(struct Hook
*, h
, A0
),
496 AROS_UFHA(Object
* , object
, A2
),
497 AROS_UFHA(APTR
, msg
, A1
))
503 if (get_selected(&scr
, &win
) == Window_type
)
505 ShowWindow (win
, WINDOW_FRONTMOST
);
509 CallHookPkt(&update_hook
, 0, 0);
514 /*********************************************************************************************/
516 AROS_UFH3(void, zip_func
,
517 AROS_UFHA(struct Hook
*, h
, A0
),
518 AROS_UFHA(Object
* , object
, A2
),
519 AROS_UFHA(APTR
, msg
, A1
))
525 if (get_selected(&scr
, &win
) == Window_type
)
530 CallHookPkt(&update_hook
, 0, 0);
535 /*********************************************************************************************/
537 AROS_UFH3(void, showall_func
,
538 AROS_UFHA(struct Hook
*, h
, A0
),
539 AROS_UFHA(Object
* , object
, A2
),
540 AROS_UFHA(APTR
, msg
, A1
))
547 /* Get Intuition's first Screen */
548 lock
= LockIBase ( 0 );
549 scr
= IntuitionBase
->FirstScreen
;
550 UnlockIBase ( lock
);
552 /* Traverse through all Screens */
555 win
= scr
->FirstWindow
;
556 /* Traverse through all Windows of current Screen */
559 /* Show Window if hidden */
560 if ( IsWindowVisible ( win
) != TRUE
)
562 ShowWindow (win
, WINDOW_FRONTMOST
);
564 win
= win
->NextWindow
;
566 scr
= scr
->NextScreen
;
570 CallHookPkt(&update_hook
, 0, 0);
575 /*********************************************************************************************/
577 AROS_UFH3(void, rescue_func
,
578 AROS_UFHA(struct Hook
*, h
, A0
),
579 AROS_UFHA(Object
* , object
, A2
),
580 AROS_UFHA(APTR
, msg
, A1
))
588 /* Get Intuition's first Screen */
589 lock
= LockIBase ( 0 );
590 scr
= IntuitionBase
->FirstScreen
;
591 UnlockIBase ( lock
);
593 /* Traverse through all Screens */
596 win
= scr
->FirstWindow
;
597 /* Traverse through all Windows of current Screen */
600 /* Move Window onto the Screen if outside */
601 if ( win
->parent
== NULL
)
604 if (win
->LeftEdge
< 0)
606 else if (win
->LeftEdge
+ win
->Width
> win
->WScreen
->Width
)
607 dx
= win
->WScreen
->Width
- win
->Width
- win
->LeftEdge
;
609 if (win
->TopEdge
+ win
->Height
> win
->WScreen
->Height
)
610 dy
= win
->WScreen
->Height
- win
->Height
- win
->TopEdge
;
611 else if (win
->TopEdge
< win
->WScreen
->BarHeight
)
613 // try to keep the screen title bar visible
614 if (win
->WScreen
->BarHeight
+ win
->Height
< win
->WScreen
->Height
)
615 dy
= -win
->TopEdge
+ win
->WScreen
->BarHeight
;
617 dy
= win
->WScreen
->Height
- win
->Height
- win
->TopEdge
;
619 MoveWindow(win
, dx
, dy
);
623 width
= win
->parent
->Width
;
624 height
= win
->parent
->Height
;
625 /* TODO: calculate reasonable values:
626 eg. this way only the Close Gadget my be visible :-( */
627 if ( win
->RelLeftEdge
< 0
628 || win
->RelTopEdge
<= -(win
->BorderTop
)
629 || win
->RelLeftEdge
> width
630 || win
->RelTopEdge
>= (height
- win
->BorderTop
) )
632 MoveWindow ( win
, - win
->RelLeftEdge
, - win
->RelTopEdge
);
635 win
= win
->NextWindow
;
637 scr
= scr
->NextScreen
;
641 CallHookPkt(&update_hook
, 0, 0);
646 /*********************************************************************************************/
648 AROS_UFH3(void, rethink_func
,
649 AROS_UFHA(struct Hook
*, h
, A0
),
650 AROS_UFHA(Object
* , object
, A2
),
651 AROS_UFHA(APTR
, msg
, A1
))
656 CallHookPkt(&update_hook
, 0, 0);
661 /*********************************************************************************************/
663 AROS_UFH3(void, about_func
,
664 AROS_UFHA(struct Hook
*, h
, A0
),
665 AROS_UFHA(Object
* , object
, A2
),
666 AROS_UFHA(APTR
, msg
, A1
))
670 MUI_Request(app
, wnd
, 0, TITLE_TXT
, CONTINUE_TXT
, ABOUT_TXT
);
675 /*********************************************************************************************/
677 AROS_UFH3(void, update_info_func
,
678 AROS_UFHA(struct Hook
*, h
, A0
),
679 AROS_UFHA(Object
* , object
, A2
),
680 AROS_UFHA(APTR
, msg
, A1
))
684 static TEXT buffer
[50];
685 struct ListEntry
*le
;
689 DoMethod(list_gad
, MUIM_List_GetEntry
, MUIV_List_GetEntry_Active
, (IPTR
)&le
);
692 set(close_gad
, MUIA_Disabled
, FALSE
);
693 set(front_gad
, MUIA_Disabled
, FALSE
);
694 set(back_gad
, MUIA_Disabled
, FALSE
);
695 set(origin_gad
, MUIA_Disabled
, FALSE
);
696 set(activate_gad
, MUIA_Disabled
, FALSE
);
697 set(zip_gad
, MUIA_Disabled
, FALSE
);
698 set(hide_gad
, MUIA_Disabled
, FALSE
);
699 set(show_gad
, MUIA_Disabled
, FALSE
);
703 set(close_gad
, MUIA_Disabled
, TRUE
);
704 set(front_gad
, MUIA_Disabled
, TRUE
);
705 set(back_gad
, MUIA_Disabled
, TRUE
);
706 set(origin_gad
, MUIA_Disabled
, TRUE
);
707 set(activate_gad
, MUIA_Disabled
, TRUE
);
708 set(zip_gad
, MUIA_Disabled
, TRUE
);
709 set(hide_gad
, MUIA_Disabled
, TRUE
);
710 set(show_gad
, MUIA_Disabled
, TRUE
);
713 if (XGET(info_wnd
, MUIA_Window_Open
))
717 switch (get_selected(&scr
, &win
))
722 set(page_gad
, MUIA_Group_ActivePage
, 0);
724 sprintf(buffer
, "%p", scr
);
725 set(info_scr_addr_gad
, MUIA_Text_Contents
, buffer
);
727 sprintf(buffer
, "%d", scr
->LeftEdge
);
728 set(info_scr_leftedge_gad
, MUIA_Text_Contents
, buffer
);
730 sprintf(buffer
, "%d", scr
->TopEdge
);
731 set(info_scr_topedge_gad
, MUIA_Text_Contents
, buffer
);
733 sprintf(buffer
, "%d", scr
->Width
);
734 set(info_scr_width_gad
, MUIA_Text_Contents
, buffer
);
736 sprintf(buffer
, "%d", scr
->Height
);
737 set(info_scr_height_gad
, MUIA_Text_Contents
, buffer
);
739 sprintf(buffer
, "0x%08x", scr
->Flags
);
740 set(info_scr_flags_gad
, MUIA_Text_Contents
, buffer
);
742 set(info_scr_title_gad
, MUIA_Text_Contents
, scr
->Title
);
743 set(info_scr_deftitle_gad
, MUIA_Text_Contents
, scr
->DefaultTitle
);
745 sprintf(buffer
, "%p", scr
->FirstWindow
);
746 set(info_scr_firstwindow_gad
, MUIA_Text_Contents
, buffer
);
752 set(page_gad
, MUIA_Group_ActivePage
, 1);
754 sprintf(buffer
, "%p", win
);
755 set(info_win_addr_gad
, MUIA_Text_Contents
, buffer
);
757 sprintf(buffer
, "%p", win
->NextWindow
);
758 set(info_win_nextwin_gad
, MUIA_Text_Contents
, buffer
);
760 sprintf(buffer
, "%d", win
->LeftEdge
);
761 set(info_win_leftedge_gad
, MUIA_Text_Contents
, buffer
);
763 sprintf(buffer
, "%d", win
->TopEdge
);
764 set(info_win_topedge_gad
, MUIA_Text_Contents
, buffer
);
766 sprintf(buffer
, "%d", win
->Height
);
767 set(info_win_height_gad
, MUIA_Text_Contents
, buffer
);
769 sprintf(buffer
, "%d", win
->Width
);
770 set(info_win_width_gad
, MUIA_Text_Contents
, buffer
);
772 sprintf(buffer
, "%d", win
->MinWidth
);
773 set(info_win_minwidth_gad
, MUIA_Text_Contents
, buffer
);
775 sprintf(buffer
, "%d", win
->MinHeight
);
776 set(info_win_minheight_gad
, MUIA_Text_Contents
, buffer
);
778 sprintf(buffer
, "%d", win
->MaxWidth
);
779 set(info_win_maxwidth_gad
, MUIA_Text_Contents
, buffer
);
781 sprintf(buffer
, "%d", win
->MaxHeight
);
782 set(info_win_maxheight_gad
, MUIA_Text_Contents
, buffer
);
784 sprintf(buffer
, "0x%08x", (unsigned int)win
->Flags
);
785 set(info_win_flags_gad
, MUIA_Text_Contents
, buffer
);
787 sprintf(buffer
, "0x%08x", (unsigned int)win
->IDCMPFlags
);
788 set(info_win_idcmp_gad
, MUIA_Text_Contents
, buffer
);
790 set(info_win_title_gad
, MUIA_Text_Contents
, win
->Title
);
792 sprintf(buffer
, "%d", win
->ReqCount
);
793 set(info_win_req_gad
, MUIA_Text_Contents
, buffer
);
795 sprintf(buffer
, "%p", win
->WScreen
);
796 set(info_win_screen_gad
, MUIA_Text_Contents
, buffer
);
798 sprintf(buffer
, "%d", win
->BorderLeft
);
799 set(info_win_borderleft_gad
, MUIA_Text_Contents
, buffer
);
801 sprintf(buffer
, "%d", win
->BorderTop
);
802 set(info_win_bordertop_gad
, MUIA_Text_Contents
, buffer
);
804 sprintf(buffer
, "%d", win
->BorderRight
);
805 set(info_win_borderright_gad
, MUIA_Text_Contents
, buffer
);
807 sprintf(buffer
, "%d", win
->BorderBottom
);
808 set(info_win_borderbottom_gad
, MUIA_Text_Contents
, buffer
);
810 sprintf(buffer
, "%p", win
->parent
);
811 set(info_win_parentwin_gad
, MUIA_Text_Contents
, buffer
);
813 sprintf(buffer
, "%p", win
->firstchild
);
814 set(info_win_firstchild_gad
, MUIA_Text_Contents
, buffer
);
816 sprintf(buffer
, "%p", win
->Parent
);
817 set(info_win_parent_gad
, MUIA_Text_Contents
, buffer
);
819 sprintf(buffer
, "%p", win
->Descendant
);
820 set(info_win_descendant_gad
, MUIA_Text_Contents
, buffer
);
824 // selected screen/window doesn't exist anymore
825 CallHookPkt(&update_hook
, 0, 0);
829 else // window is open but no entry is selected
831 set(info_scr_addr_gad
, MUIA_Text_Contents
, NULL
);
832 set(info_scr_leftedge_gad
, MUIA_Text_Contents
, NULL
);
833 set(info_scr_topedge_gad
, MUIA_Text_Contents
, NULL
);
834 set(info_scr_width_gad
, MUIA_Text_Contents
, NULL
);
835 set(info_scr_height_gad
, MUIA_Text_Contents
, NULL
);
836 set(info_scr_flags_gad
, MUIA_Text_Contents
, NULL
);
837 set(info_scr_title_gad
, MUIA_Text_Contents
, NULL
);
838 set(info_scr_deftitle_gad
, MUIA_Text_Contents
, NULL
);
839 set(info_scr_firstwindow_gad
, MUIA_Text_Contents
, NULL
);
840 set(info_win_addr_gad
, MUIA_Text_Contents
, NULL
);
841 set(info_win_nextwin_gad
, MUIA_Text_Contents
, NULL
);
842 set(info_win_leftedge_gad
, MUIA_Text_Contents
, NULL
);
843 set(info_win_topedge_gad
, MUIA_Text_Contents
, NULL
);
844 set(info_win_height_gad
, MUIA_Text_Contents
, NULL
);
845 set(info_win_width_gad
, MUIA_Text_Contents
, NULL
);
846 set(info_win_minwidth_gad
, MUIA_Text_Contents
, NULL
);
847 set(info_win_minheight_gad
, MUIA_Text_Contents
, NULL
);
848 set(info_win_maxwidth_gad
, MUIA_Text_Contents
, NULL
);
849 set(info_win_maxheight_gad
, MUIA_Text_Contents
, NULL
);
850 set(info_win_flags_gad
, MUIA_Text_Contents
, NULL
);
851 set(info_win_idcmp_gad
, MUIA_Text_Contents
, NULL
);
852 set(info_win_title_gad
, MUIA_Text_Contents
, NULL
);
853 set(info_win_req_gad
, MUIA_Text_Contents
, NULL
);
854 set(info_win_screen_gad
, MUIA_Text_Contents
, NULL
);
855 set(info_win_borderleft_gad
, MUIA_Text_Contents
, NULL
);
856 set(info_win_bordertop_gad
, MUIA_Text_Contents
, NULL
);
857 set(info_win_borderright_gad
, MUIA_Text_Contents
, NULL
);
858 set(info_win_borderbottom_gad
, MUIA_Text_Contents
, NULL
);
859 set(info_win_parentwin_gad
, MUIA_Text_Contents
, NULL
);
860 set(info_win_firstchild_gad
, MUIA_Text_Contents
, NULL
);
861 set(info_win_parent_gad
, MUIA_Text_Contents
, NULL
);
862 set(info_win_descendant_gad
, MUIA_Text_Contents
, NULL
);
869 /*********************************************************************************************/
871 AROS_UFH3(void, openinfo_func
,
872 AROS_UFHA(struct Hook
*, h
, A0
),
873 AROS_UFHA(Object
* , object
, A2
),
874 AROS_UFHA(APTR
, msg
, A1
))
878 set(info_wnd
, MUIA_Window_Open
, TRUE
);
879 CallHookPkt(&updateinfo_hook
, 0, 0);
883 /*********************************************************************************************/
885 static void MakeGUI(void)
887 Object
*menu
= MUI_MakeObject(MUIO_MenustripNM
, &nm
, 0);
889 display_hook
.h_Entry
= (HOOKFUNC
)display_func
;
890 construct_hook
.h_Entry
= (HOOKFUNC
)construct_func
;
891 destruct_hook
.h_Entry
= (HOOKFUNC
)destruct_func
;
893 close_hook
.h_Entry
= (HOOKFUNC
)close_func
;
894 front_hook
.h_Entry
= (HOOKFUNC
)front_func
;
895 back_hook
.h_Entry
= (HOOKFUNC
)back_func
;
896 origin_hook
.h_Entry
= (HOOKFUNC
)origin_func
;
897 activate_hook
.h_Entry
= (HOOKFUNC
)activate_func
;
898 zip_hook
.h_Entry
= (HOOKFUNC
)zip_func
;
899 hide_hook
.h_Entry
= (HOOKFUNC
)hide_func
;
900 show_hook
.h_Entry
= (HOOKFUNC
)show_func
;
902 update_hook
.h_Entry
= (HOOKFUNC
)update_func
;
903 rescue_hook
.h_Entry
= (HOOKFUNC
)rescue_func
;
904 showall_hook
.h_Entry
= (HOOKFUNC
)showall_func
;
905 rethink_hook
.h_Entry
= (HOOKFUNC
)rethink_func
;
906 about_hook
.h_Entry
= (HOOKFUNC
)about_func
;
908 openinfo_hook
.h_Entry
= (HOOKFUNC
)openinfo_func
;
909 updateinfo_hook
.h_Entry
= (HOOKFUNC
)update_info_func
;
911 app
= (Object
*)ApplicationObject
,
912 MUIA_Application_Title
, (IPTR
)"WiMP",
913 MUIA_Application_Version
, (IPTR
)version
,
914 MUIA_Application_Copyright
, (IPTR
)"Copyright © 1995-2009, The AROS Development Team",
915 MUIA_Application_Author
, (IPTR
)"The AROS Development Team",
916 MUIA_Application_Description
, (IPTR
)"Window Manipulator",
917 MUIA_Application_Base
, (IPTR
)"WIMP",
918 MUIA_Application_SingleTask
, TRUE
,
919 MUIA_Application_Menustrip
, (IPTR
)menu
,
920 SubWindow
, (IPTR
)(wnd
= (Object
*)WindowObject
,
921 MUIA_Window_Title
, (IPTR
)TITLE_TXT
,
922 MUIA_Window_ID
, MAKE_ID('W', 'I', 'M', 'P'),
923 WindowContents
, (IPTR
)(VGroup
,
924 Child
, (IPTR
)(VGroup
,
925 GroupFrameT("Screen/Window List"),
926 Child
, (IPTR
)(ListviewObject
,
927 MUIA_Listview_List
, (IPTR
)(list_gad
= (Object
*)ListObject
,
929 MUIA_List_Format
, (IPTR
)"BAR,BAR,P=\033c BAR,P=\033c BAR,BAR,BAR",
930 MUIA_List_ConstructHook
, (IPTR
)&construct_hook
,
931 MUIA_List_DestructHook
, (IPTR
)&destruct_hook
,
932 MUIA_List_DisplayHook
, (IPTR
)&display_hook
,
933 MUIA_List_Title
, TRUE
,
937 Child
, (IPTR
)(HGroup
,
938 Child
, (IPTR
)(close_gad
= SimpleButton("\033iKill")),
939 Child
, (IPTR
)(front_gad
= SimpleButton("To _Front")),
940 Child
, (IPTR
)(back_gad
= SimpleButton("To _Back")),
941 Child
, (IPTR
)(origin_gad
= SimpleButton("Move to _Origin")),
942 Child
, (IPTR
)(activate_gad
= SimpleButton("_Activate")),
943 Child
, (IPTR
)(zip_gad
= SimpleButton("_Zip")),
944 Child
, (IPTR
)(hide_gad
= SimpleButton("_Hide")),
945 Child
, (IPTR
)(show_gad
= SimpleButton("_Show")),
947 Child
, (IPTR
)(HGroup
,
948 Child
, (IPTR
)(update_gad
= SimpleButton("_Update List")),
949 Child
, (IPTR
)(rescue_gad
= SimpleButton("_Rescue all Windows")),
950 Child
, (IPTR
)(showall_gad
= SimpleButton("Show all Windows")),
951 Child
, (IPTR
)(rethink_gad
= SimpleButton("Rethink Display")),
952 Child
, (IPTR
)(about_gad
= SimpleButton("About")),
957 SubWindow
, (IPTR
)(info_wnd
= (Object
*)WindowObject
,
958 MUIA_Window_Title
, (IPTR
)INFOTITLE_TXT
,
959 MUIA_Window_ID
, MAKE_ID('W', 'I', 'N', 'F'),
960 WindowContents
, (IPTR
)(page_gad
= (Object
*)PageGroup
,
961 Child
, (IPTR
)(HGroup
,
962 Child
, (IPTR
)(ColGroup(2),
963 GroupFrameT("Screen"),
965 Child
, (IPTR
)Label("Address"),
966 Child
, (IPTR
)(info_scr_addr_gad
= (Object
*)TextObject
,
968 MUIA_Text_Contents
, (IPTR
)"WWWWWWWWWWWWWWWWWWWWWWWWWWWWWW",
969 MUIA_Text_SetMin
, TRUE
,
971 Child
, (IPTR
)Label("LeftEdge"),
972 Child
, (IPTR
)(info_scr_leftedge_gad
= (Object
*)TextObject
, TextFrame
, End
),
973 Child
, (IPTR
)Label("TopEdge"),
974 Child
, (IPTR
)(info_scr_topedge_gad
= (Object
*)TextObject
, TextFrame
, End
),
975 Child
, (IPTR
)Label("Width"),
976 Child
, (IPTR
)(info_scr_width_gad
= (Object
*)TextObject
, TextFrame
, End
),
977 Child
, (IPTR
)Label("Height"),
978 Child
, (IPTR
)(info_scr_height_gad
= (Object
*)TextObject
, TextFrame
, End
),
979 Child
, (IPTR
)Label("Flags"),
980 Child
, (IPTR
)(info_scr_flags_gad
= (Object
*)TextObject
, TextFrame
, End
),
981 Child
, (IPTR
)Label("Title"),
982 Child
, (IPTR
)(info_scr_title_gad
= (Object
*)TextObject
, TextFrame
, End
),
983 Child
, (IPTR
)Label("DefaultTitle"),
984 Child
, (IPTR
)(info_scr_deftitle_gad
= (Object
*)TextObject
, TextFrame
, End
),
985 Child
, (IPTR
)Label("FirstWindow"),
986 Child
, (IPTR
)(info_scr_firstwindow_gad
= (Object
*)TextObject
, TextFrame
, End
),
989 Child
, (IPTR
)(HGroup
,
990 Child
, (IPTR
)(ColGroup(2),
991 GroupFrameT("Window"),
992 Child
, (IPTR
)Label("Address"),
993 Child
, (IPTR
)(info_win_addr_gad
= (Object
*)TextObject
,
995 MUIA_Text_Contents
, (IPTR
)"WWWWWWWWWWWWWWWWWWWWWWWWWWWWWW",
996 MUIA_Text_SetMin
, TRUE
,
998 Child
, (IPTR
)Label("NextWindow"),
999 Child
, (IPTR
)(info_win_nextwin_gad
= (Object
*)TextObject
, TextFrame
, End
),
1000 Child
, (IPTR
)Label("LeftEdge"),
1001 Child
, (IPTR
)(info_win_leftedge_gad
= (Object
*)TextObject
, TextFrame
, End
),
1002 Child
, (IPTR
)Label("TopEdge"),
1003 Child
, (IPTR
)(info_win_topedge_gad
= (Object
*)TextObject
, TextFrame
, End
),
1004 Child
, (IPTR
)Label("Width"),
1005 Child
, (IPTR
)(info_win_width_gad
= (Object
*)TextObject
, TextFrame
, End
),
1006 Child
, (IPTR
)Label("Height"),
1007 Child
, (IPTR
)(info_win_height_gad
= (Object
*)TextObject
, TextFrame
, End
),
1008 Child
, (IPTR
)Label("MinWidth"),
1009 Child
, (IPTR
)(info_win_minwidth_gad
= (Object
*)TextObject
, TextFrame
, End
),
1010 Child
, (IPTR
)Label("MinHeight"),
1011 Child
, (IPTR
)(info_win_minheight_gad
= (Object
*)TextObject
, TextFrame
, End
),
1012 Child
, (IPTR
)Label("MaxWidth"),
1013 Child
, (IPTR
)(info_win_maxwidth_gad
= (Object
*)TextObject
, TextFrame
, End
),
1014 Child
, (IPTR
)Label("MaxHeight"),
1015 Child
, (IPTR
)(info_win_maxheight_gad
= (Object
*)TextObject
, TextFrame
, End
),
1016 Child
, (IPTR
)Label("Flags"),
1017 Child
, (IPTR
)(info_win_flags_gad
= (Object
*)TextObject
, TextFrame
, End
),
1018 Child
, (IPTR
)Label("IDCMPFlags"),
1019 Child
, (IPTR
)(info_win_idcmp_gad
= (Object
*)TextObject
, TextFrame
, End
),
1020 Child
, (IPTR
)Label("Title"),
1021 Child
, (IPTR
)(info_win_title_gad
= (Object
*)TextObject
, TextFrame
, End
),
1022 Child
, (IPTR
)Label("ReqCount"),
1023 Child
, (IPTR
)(info_win_req_gad
= (Object
*)TextObject
, TextFrame
, End
),
1024 Child
, (IPTR
)Label("WScreen"),
1025 Child
, (IPTR
)(info_win_screen_gad
= (Object
*)TextObject
, TextFrame
, End
),
1026 Child
, (IPTR
)Label("BorderLeft"),
1027 Child
, (IPTR
)(info_win_borderleft_gad
= (Object
*)TextObject
, TextFrame
, End
),
1028 Child
, (IPTR
)Label("BorderTop"),
1029 Child
, (IPTR
)(info_win_bordertop_gad
= (Object
*)TextObject
, TextFrame
, End
),
1030 Child
, (IPTR
)Label("BorderRight"),
1031 Child
, (IPTR
)(info_win_borderright_gad
= (Object
*)TextObject
, TextFrame
, End
),
1032 Child
, (IPTR
)Label("BoderBottom"),
1033 Child
, (IPTR
)(info_win_borderbottom_gad
= (Object
*)TextObject
, TextFrame
, End
),
1034 Child
, (IPTR
)Label("Parent Window"),
1035 Child
, (IPTR
)(info_win_parentwin_gad
= (Object
*)TextObject
, TextFrame
, End
),
1036 Child
, (IPTR
)Label("First Child"),
1037 Child
, (IPTR
)(info_win_firstchild_gad
= (Object
*)TextObject
, TextFrame
, End
),
1038 Child
, (IPTR
)Label("Parent"),
1039 Child
, (IPTR
)(info_win_parent_gad
= (Object
*)TextObject
, TextFrame
, End
),
1040 Child
, (IPTR
)Label("Descendant"),
1041 Child
, (IPTR
)(info_win_descendant_gad
= (Object
*)TextObject
, TextFrame
, End
),
1049 Cleanup(NULL
); // Probably double start
1051 DoMethod(wnd
, MUIM_Notify
, MUIA_Window_CloseRequest
, TRUE
,
1052 app
, 2, MUIM_Application_ReturnID
, MUIV_Application_ReturnID_Quit
);
1054 DoMethod(info_wnd
, MUIM_Notify
, MUIA_Window_CloseRequest
, TRUE
,
1055 info_wnd
, 3, MUIM_Set
, MUIA_Window_Open
, FALSE
);
1057 DoMethod(list_gad
, MUIM_Notify
, MUIA_List_Active
, MUIV_EveryTime
,
1058 (IPTR
)app
, 2, MUIM_CallHook
, (IPTR
)&updateinfo_hook
);
1060 DoMethod(list_gad
, MUIM_Notify
, MUIA_Listview_DoubleClick
, TRUE
,
1061 (IPTR
)app
, 2, MUIM_CallHook
, (IPTR
)&openinfo_hook
);
1065 DoMethod(app
, MUIM_Notify
, MUIA_Application_MenuAction
, MN_QUIT
,
1066 (IPTR
)app
, 2, MUIM_Application_ReturnID
, MUIV_Application_ReturnID_Quit
);
1068 DoMethod(app
, MUIM_Notify
, MUIA_Application_MenuAction
, MN_ABOUT
,
1069 (IPTR
)app
, 2, MUIM_CallHook
, (IPTR
)&about_hook
);
1071 DoMethod(app
, MUIM_Notify
, MUIA_Application_MenuAction
, MN_UPDATE
,
1072 (IPTR
)app
, 2, MUIM_CallHook
, (IPTR
)&update_hook
);
1074 DoMethod(app
, MUIM_Notify
, MUIA_Application_MenuAction
, MN_KILL
,
1075 (IPTR
)app
, 2, MUIM_CallHook
, (IPTR
)&close_hook
);
1077 DoMethod(app
, MUIM_Notify
, MUIA_Application_MenuAction
, MN_FRONT
,
1078 (IPTR
)app
, 2, MUIM_CallHook
, (IPTR
)&front_hook
);
1080 DoMethod(app
, MUIM_Notify
, MUIA_Application_MenuAction
, MN_BACK
,
1081 (IPTR
)app
, 2, MUIM_CallHook
, (IPTR
)&back_hook
);
1083 DoMethod(app
, MUIM_Notify
, MUIA_Application_MenuAction
, MN_ORIGIN
,
1084 (IPTR
)app
, 2, MUIM_CallHook
, (IPTR
)&origin_hook
);
1086 DoMethod(app
, MUIM_Notify
, MUIA_Application_MenuAction
, MN_ACTIVATE
,
1087 (IPTR
)app
, 2, MUIM_CallHook
, (IPTR
)&activate_hook
);
1089 DoMethod(app
, MUIM_Notify
, MUIA_Application_MenuAction
, MN_ZIP
,
1090 (IPTR
)app
, 2, MUIM_CallHook
, (IPTR
)&zip_hook
);
1092 DoMethod(app
, MUIM_Notify
, MUIA_Application_MenuAction
, MN_HIDE
,
1093 (IPTR
)app
, 2, MUIM_CallHook
, (IPTR
)&hide_hook
);
1095 DoMethod(app
, MUIM_Notify
, MUIA_Application_MenuAction
, MN_SHOW
,
1096 (IPTR
)app
, 2, MUIM_CallHook
, (IPTR
)&show_hook
);
1098 DoMethod(app
, MUIM_Notify
, MUIA_Application_MenuAction
, MN_INFO
,
1099 (IPTR
)app
, 2, MUIM_CallHook
, (IPTR
)&openinfo_hook
);
1101 DoMethod(app
, MUIM_Notify
, MUIA_Application_MenuAction
, MN_RESCUE
,
1102 (IPTR
)app
, 2, MUIM_CallHook
, (IPTR
)&rescue_hook
);
1104 DoMethod(app
, MUIM_Notify
, MUIA_Application_MenuAction
, MN_SHOWALL
,
1105 (IPTR
)app
, 2, MUIM_CallHook
, (IPTR
)&showall_hook
);
1107 DoMethod(app
, MUIM_Notify
, MUIA_Application_MenuAction
, MN_RETHINK
,
1108 (IPTR
)app
, 2, MUIM_CallHook
, (IPTR
)&rethink_hook
);
1111 // buttons first row
1112 DoMethod(close_gad
, MUIM_Notify
, MUIA_Pressed
, FALSE
,
1113 (IPTR
)app
, 2, MUIM_CallHook
, (IPTR
)&close_hook
);
1115 DoMethod(front_gad
, MUIM_Notify
, MUIA_Pressed
, FALSE
,
1116 (IPTR
)app
, 2, MUIM_CallHook
, (IPTR
)&front_hook
);
1118 DoMethod(back_gad
, MUIM_Notify
, MUIA_Pressed
, FALSE
,
1119 (IPTR
)app
, 2, MUIM_CallHook
, (IPTR
)&back_hook
);
1121 DoMethod(origin_gad
, MUIM_Notify
, MUIA_Pressed
, FALSE
,
1122 (IPTR
)app
, 2, MUIM_CallHook
, (IPTR
)&origin_hook
);
1124 DoMethod(activate_gad
, MUIM_Notify
, MUIA_Pressed
, FALSE
,
1125 (IPTR
)app
, 2, MUIM_CallHook
, (IPTR
)&activate_hook
);
1127 DoMethod(zip_gad
, MUIM_Notify
, MUIA_Pressed
, FALSE
,
1128 (IPTR
)app
, 2, MUIM_CallHook
, (IPTR
)&zip_hook
);
1130 DoMethod(hide_gad
, MUIM_Notify
, MUIA_Pressed
, FALSE
,
1131 (IPTR
)app
, 2, MUIM_CallHook
, (IPTR
)&hide_hook
);
1133 DoMethod(show_gad
, MUIM_Notify
, MUIA_Pressed
, FALSE
,
1134 (IPTR
)app
, 2, MUIM_CallHook
, (IPTR
)&show_hook
);
1137 // buttons second row
1138 DoMethod(update_gad
, MUIM_Notify
, MUIA_Pressed
, FALSE
,
1139 (IPTR
)app
, 2, MUIM_CallHook
, (IPTR
)&update_hook
);
1141 DoMethod(rescue_gad
, MUIM_Notify
, MUIA_Pressed
, FALSE
,
1142 (IPTR
)app
, 2, MUIM_CallHook
, (IPTR
)&rescue_hook
);
1144 DoMethod(showall_gad
, MUIM_Notify
, MUIA_Pressed
, FALSE
,
1145 (IPTR
)app
, 2, MUIM_CallHook
, (IPTR
)&showall_hook
);
1147 DoMethod(rethink_gad
, MUIM_Notify
, MUIA_Pressed
, FALSE
,
1148 (IPTR
)app
, 2, MUIM_CallHook
, (IPTR
)&rethink_hook
);
1150 DoMethod(about_gad
, MUIM_Notify
, MUIA_Pressed
, FALSE
,
1151 (IPTR
)app
, 2, MUIM_CallHook
, (IPTR
)&about_hook
);
1153 set(wnd
, MUIA_Window_Open
, TRUE
);
1154 CallHookPkt(&update_hook
, 0, 0);
1155 CallHookPkt(&updateinfo_hook
, 0, 0);
1156 DoMethod(app
, MUIM_Application_Execute
);
1159 /*********************************************************************************************/
1161 static void Cleanup(CONST_STRPTR txt
)
1163 MUI_DisposeObject(app
);
1166 MUI_Request(app
, wnd
, 0, TITLE_TXT
, "OK", txt
);
1172 /*********************************************************************************************/
1174 int main(int argc
, char **argv
)