2 Copyright © 1995-2009, 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>
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>
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
;
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-2009 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";
111 static const char version
[] = "$VER: WiMP 0.13 (06.01.2009) © 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 /*********************************************************************************************/
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
},
165 /*********************************************************************************************/
167 static LONG
get_selected(struct Screen
**scr
, struct Window
**win
)
172 struct ListEntry
*le
;
173 DoMethod(list_gad
, MUIM_List_GetEntry
, MUIV_List_GetEntry_Active
, (IPTR
)&le
);
177 lock
= LockIBase ( 0 );
178 *scr
= IntuitionBase
->FirstScreen
;
179 UnlockIBase ( lock
);
180 /* Traverse through all Screens */
183 if ((le
->type
== Screen_type
) && (le
->aptr
== *scr
))
188 /* Traverse through all Windows of current Screen */
189 *win
= (*scr
)->FirstWindow
;
192 if ((le
->type
== Window_type
) && (le
->aptr
== *win
))
197 *win
= (*win
)->NextWindow
;
199 *scr
= (*scr
)->NextScreen
;
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
))
216 if (msg
->type
== Window_type
)
218 array
[0] = " \033bWindow";
222 array
[0] = "\033b\033uScreen";
224 array
[1] = msg
->address
;
225 array
[2] = msg
->size
;
227 array
[4] = msg
->status
;
228 array
[5] = msg
->title
;
233 array
[1] = "Address";
235 array
[3] = "Position";
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
))
252 struct ListEntry
*new = AllocPooled(pool
, sizeof(*msg
));
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
))
270 FreePooled(pool
, msg
, sizeof(*msg
));
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
))
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 */
299 entry
.type
= Screen_type
;
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
? (char *)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
;
312 entry
.type
= Window_type
;
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
? (char *)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
);
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
))
344 switch (get_selected(&scr
, &win
))
347 if (MUI_Request(app
, wnd
, 0, TITLE_TXT
, YESNO_TXT
, CLOSESCREEN_TXT
))
353 if (MUI_Request(app
, wnd
, 0, TITLE_TXT
, YESNO_TXT
, CLOSEWINDOW_TXT
))
360 CallHookPkt(&update_hook
, 0, 0);
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
))
376 switch (get_selected(&scr
, &win
))
386 CallHookPkt(&update_hook
, 0, 0);
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
))
402 switch (get_selected(&scr
, &win
))
412 CallHookPkt(&update_hook
, 0, 0);
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
))
428 switch (get_selected(&scr
, &win
))
431 MoveScreen ( scr
, -scr
->LeftEdge
, -scr
->TopEdge
);
434 MoveWindow ( win
, -win
->RelLeftEdge
, -win
->RelTopEdge
);
439 CallHookPkt(&update_hook
, 0, 0);
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
))
455 if (get_selected(&scr
, &win
) == Window_type
)
457 ActivateWindow ( win
);
460 CallHookPkt(&update_hook
, 0, 0);
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
))
476 if (get_selected(&scr
, &win
) == Window_type
)
478 if ((struct Window
*)XGET(wnd
, MUIA_Window_Window
) != win
) // You can't hide WiMP
485 CallHookPkt(&update_hook
, 0, 0);
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
))
501 if (get_selected(&scr
, &win
) == Window_type
)
507 CallHookPkt(&update_hook
, 0, 0);
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
))
523 if (get_selected(&scr
, &win
) == Window_type
)
528 CallHookPkt(&update_hook
, 0, 0);
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
))
545 /* Get Intuition's first Screen */
546 lock
= LockIBase ( 0 );
547 scr
= IntuitionBase
->FirstScreen
;
548 UnlockIBase ( lock
);
550 /* Traverse through all Screens */
553 win
= scr
->FirstWindow
;
554 /* Traverse through all Windows of current Screen */
557 /* Show Window if hidden */
558 if ( IsWindowVisible ( win
) != TRUE
)
562 win
= win
->NextWindow
;
564 scr
= scr
->NextScreen
;
568 CallHookPkt(&update_hook
, 0, 0);
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
))
586 /* Get Intuition's first Screen */
587 lock
= LockIBase ( 0 );
588 scr
= IntuitionBase
->FirstScreen
;
589 UnlockIBase ( lock
);
591 /* Traverse through all Screens */
594 win
= scr
->FirstWindow
;
595 /* Traverse through all Windows of current Screen */
598 /* Move Window onto the Screen if outside */
599 if ( win
->parent
== NULL
)
602 if (win
->LeftEdge
< 0)
604 else if (win
->LeftEdge
+ win
->Width
> win
->WScreen
->Width
)
605 dx
= win
->WScreen
->Width
- win
->Width
- win
->LeftEdge
;
607 if (win
->TopEdge
+ win
->Height
> win
->WScreen
->Height
)
608 dy
= win
->WScreen
->Height
- win
->Height
- win
->TopEdge
;
609 else if (win
->TopEdge
< win
->WScreen
->BarHeight
)
611 // try to keep the screen title bar visible
612 if (win
->WScreen
->BarHeight
+ win
->Height
< win
->WScreen
->Height
)
613 dy
= -win
->TopEdge
+ win
->WScreen
->BarHeight
;
615 dy
= win
->WScreen
->Height
- win
->Height
- win
->TopEdge
;
617 MoveWindow(win
, dx
, dy
);
621 width
= win
->parent
->Width
;
622 height
= win
->parent
->Height
;
623 /* TODO: calculate reasonable values:
624 eg. this way only the Close Gadget my be visible :-( */
625 if ( win
->RelLeftEdge
< 0
626 || win
->RelTopEdge
<= -(win
->BorderTop
)
627 || win
->RelLeftEdge
> width
628 || win
->RelTopEdge
>= (height
- win
->BorderTop
) )
630 MoveWindow ( win
, - win
->RelLeftEdge
, - win
->RelTopEdge
);
633 win
= win
->NextWindow
;
635 scr
= scr
->NextScreen
;
639 CallHookPkt(&update_hook
, 0, 0);
644 /*********************************************************************************************/
646 AROS_UFH3(void, rethink_func
,
647 AROS_UFHA(struct Hook
*, h
, A0
),
648 AROS_UFHA(Object
* , object
, A2
),
649 AROS_UFHA(APTR
, msg
, A1
))
654 CallHookPkt(&update_hook
, 0, 0);
659 /*********************************************************************************************/
661 AROS_UFH3(void, about_func
,
662 AROS_UFHA(struct Hook
*, h
, A0
),
663 AROS_UFHA(Object
* , object
, A2
),
664 AROS_UFHA(APTR
, msg
, A1
))
668 MUI_Request(app
, wnd
, 0, TITLE_TXT
, CONTINUE_TXT
, ABOUT_TXT
);
673 /*********************************************************************************************/
675 AROS_UFH3(void, update_info_func
,
676 AROS_UFHA(struct Hook
*, h
, A0
),
677 AROS_UFHA(Object
* , object
, A2
),
678 AROS_UFHA(APTR
, msg
, A1
))
682 static TEXT buffer
[50];
683 struct ListEntry
*le
;
687 DoMethod(list_gad
, MUIM_List_GetEntry
, MUIV_List_GetEntry_Active
, (IPTR
)&le
);
690 set(close_gad
, MUIA_Disabled
, FALSE
);
691 set(front_gad
, MUIA_Disabled
, FALSE
);
692 set(back_gad
, MUIA_Disabled
, FALSE
);
693 set(origin_gad
, MUIA_Disabled
, FALSE
);
694 set(activate_gad
, MUIA_Disabled
, FALSE
);
695 set(zip_gad
, MUIA_Disabled
, FALSE
);
696 set(hide_gad
, MUIA_Disabled
, FALSE
);
697 set(show_gad
, MUIA_Disabled
, FALSE
);
701 set(close_gad
, MUIA_Disabled
, TRUE
);
702 set(front_gad
, MUIA_Disabled
, TRUE
);
703 set(back_gad
, MUIA_Disabled
, TRUE
);
704 set(origin_gad
, MUIA_Disabled
, TRUE
);
705 set(activate_gad
, MUIA_Disabled
, TRUE
);
706 set(zip_gad
, MUIA_Disabled
, TRUE
);
707 set(hide_gad
, MUIA_Disabled
, TRUE
);
708 set(show_gad
, MUIA_Disabled
, TRUE
);
711 if (XGET(info_wnd
, MUIA_Window_Open
))
715 switch (get_selected(&scr
, &win
))
720 set(page_gad
, MUIA_Group_ActivePage
, 0);
722 sprintf(buffer
, "%p", scr
);
723 set(info_scr_addr_gad
, MUIA_Text_Contents
, buffer
);
725 sprintf(buffer
, "%d", scr
->LeftEdge
);
726 set(info_scr_leftedge_gad
, MUIA_Text_Contents
, buffer
);
728 sprintf(buffer
, "%d", scr
->TopEdge
);
729 set(info_scr_topedge_gad
, MUIA_Text_Contents
, buffer
);
731 sprintf(buffer
, "%d", scr
->Width
);
732 set(info_scr_width_gad
, MUIA_Text_Contents
, buffer
);
734 sprintf(buffer
, "%d", scr
->Height
);
735 set(info_scr_height_gad
, MUIA_Text_Contents
, buffer
);
737 sprintf(buffer
, "0x%08x", scr
->Flags
);
738 set(info_scr_flags_gad
, MUIA_Text_Contents
, buffer
);
740 set(info_scr_title_gad
, MUIA_Text_Contents
, scr
->Title
);
741 set(info_scr_deftitle_gad
, MUIA_Text_Contents
, scr
->DefaultTitle
);
743 sprintf(buffer
, "%p", scr
->FirstWindow
);
744 set(info_scr_firstwindow_gad
, MUIA_Text_Contents
, buffer
);
750 set(page_gad
, MUIA_Group_ActivePage
, 1);
752 sprintf(buffer
, "%p", win
);
753 set(info_win_addr_gad
, MUIA_Text_Contents
, buffer
);
755 sprintf(buffer
, "%p", win
->NextWindow
);
756 set(info_win_nextwin_gad
, MUIA_Text_Contents
, buffer
);
758 sprintf(buffer
, "%d", win
->LeftEdge
);
759 set(info_win_leftedge_gad
, MUIA_Text_Contents
, buffer
);
761 sprintf(buffer
, "%d", win
->TopEdge
);
762 set(info_win_topedge_gad
, MUIA_Text_Contents
, buffer
);
764 sprintf(buffer
, "%d", win
->Height
);
765 set(info_win_height_gad
, MUIA_Text_Contents
, buffer
);
767 sprintf(buffer
, "%d", win
->Width
);
768 set(info_win_width_gad
, MUIA_Text_Contents
, buffer
);
770 sprintf(buffer
, "%d", win
->MinWidth
);
771 set(info_win_minwidth_gad
, MUIA_Text_Contents
, buffer
);
773 sprintf(buffer
, "%d", win
->MinHeight
);
774 set(info_win_minheight_gad
, MUIA_Text_Contents
, buffer
);
776 sprintf(buffer
, "%d", win
->MaxWidth
);
777 set(info_win_maxwidth_gad
, MUIA_Text_Contents
, buffer
);
779 sprintf(buffer
, "%d", win
->MaxHeight
);
780 set(info_win_maxheight_gad
, MUIA_Text_Contents
, buffer
);
782 sprintf(buffer
, "0x%08x", win
->Flags
);
783 set(info_win_flags_gad
, MUIA_Text_Contents
, buffer
);
785 sprintf(buffer
, "0x%08x", win
->IDCMPFlags
);
786 set(info_win_idcmp_gad
, MUIA_Text_Contents
, buffer
);
788 set(info_win_title_gad
, MUIA_Text_Contents
, win
->Title
);
790 sprintf(buffer
, "%d", win
->ReqCount
);
791 set(info_win_req_gad
, MUIA_Text_Contents
, buffer
);
793 sprintf(buffer
, "%p", win
->WScreen
);
794 set(info_win_screen_gad
, MUIA_Text_Contents
, buffer
);
796 sprintf(buffer
, "%d", win
->BorderLeft
);
797 set(info_win_borderleft_gad
, MUIA_Text_Contents
, buffer
);
799 sprintf(buffer
, "%d", win
->BorderTop
);
800 set(info_win_bordertop_gad
, MUIA_Text_Contents
, buffer
);
802 sprintf(buffer
, "%d", win
->BorderRight
);
803 set(info_win_borderright_gad
, MUIA_Text_Contents
, buffer
);
805 sprintf(buffer
, "%d", win
->BorderBottom
);
806 set(info_win_borderbottom_gad
, MUIA_Text_Contents
, buffer
);
808 sprintf(buffer
, "%p", win
->parent
);
809 set(info_win_parentwin_gad
, MUIA_Text_Contents
, buffer
);
811 sprintf(buffer
, "%p", win
->firstchild
);
812 set(info_win_firstchild_gad
, MUIA_Text_Contents
, buffer
);
814 sprintf(buffer
, "%p", win
->Parent
);
815 set(info_win_parent_gad
, MUIA_Text_Contents
, buffer
);
817 sprintf(buffer
, "%p", win
->Descendant
);
818 set(info_win_descendant_gad
, MUIA_Text_Contents
, buffer
);
822 // selected screen/window doesn't exist anymore
823 CallHookPkt(&update_hook
, 0, 0);
827 else // window is open but no entry is selected
829 set(info_scr_addr_gad
, MUIA_Text_Contents
, NULL
);
830 set(info_scr_leftedge_gad
, MUIA_Text_Contents
, NULL
);
831 set(info_scr_topedge_gad
, MUIA_Text_Contents
, NULL
);
832 set(info_scr_width_gad
, MUIA_Text_Contents
, NULL
);
833 set(info_scr_height_gad
, MUIA_Text_Contents
, NULL
);
834 set(info_scr_flags_gad
, MUIA_Text_Contents
, NULL
);
835 set(info_scr_title_gad
, MUIA_Text_Contents
, NULL
);
836 set(info_scr_deftitle_gad
, MUIA_Text_Contents
, NULL
);
837 set(info_scr_firstwindow_gad
, MUIA_Text_Contents
, NULL
);
838 set(info_win_addr_gad
, MUIA_Text_Contents
, NULL
);
839 set(info_win_nextwin_gad
, MUIA_Text_Contents
, NULL
);
840 set(info_win_leftedge_gad
, MUIA_Text_Contents
, NULL
);
841 set(info_win_topedge_gad
, MUIA_Text_Contents
, NULL
);
842 set(info_win_height_gad
, MUIA_Text_Contents
, NULL
);
843 set(info_win_width_gad
, MUIA_Text_Contents
, NULL
);
844 set(info_win_minwidth_gad
, MUIA_Text_Contents
, NULL
);
845 set(info_win_minheight_gad
, MUIA_Text_Contents
, NULL
);
846 set(info_win_maxwidth_gad
, MUIA_Text_Contents
, NULL
);
847 set(info_win_maxheight_gad
, MUIA_Text_Contents
, NULL
);
848 set(info_win_flags_gad
, MUIA_Text_Contents
, NULL
);
849 set(info_win_idcmp_gad
, MUIA_Text_Contents
, NULL
);
850 set(info_win_title_gad
, MUIA_Text_Contents
, NULL
);
851 set(info_win_req_gad
, MUIA_Text_Contents
, NULL
);
852 set(info_win_screen_gad
, MUIA_Text_Contents
, NULL
);
853 set(info_win_borderleft_gad
, MUIA_Text_Contents
, NULL
);
854 set(info_win_bordertop_gad
, MUIA_Text_Contents
, NULL
);
855 set(info_win_borderright_gad
, MUIA_Text_Contents
, NULL
);
856 set(info_win_borderbottom_gad
, MUIA_Text_Contents
, NULL
);
857 set(info_win_parentwin_gad
, MUIA_Text_Contents
, NULL
);
858 set(info_win_firstchild_gad
, MUIA_Text_Contents
, NULL
);
859 set(info_win_parent_gad
, MUIA_Text_Contents
, NULL
);
860 set(info_win_descendant_gad
, MUIA_Text_Contents
, NULL
);
867 /*********************************************************************************************/
869 AROS_UFH3(void, openinfo_func
,
870 AROS_UFHA(struct Hook
*, h
, A0
),
871 AROS_UFHA(Object
* , object
, A2
),
872 AROS_UFHA(APTR
, msg
, A1
))
876 set(info_wnd
, MUIA_Window_Open
, TRUE
);
877 CallHookPkt(&updateinfo_hook
, 0, 0);
881 /*********************************************************************************************/
883 static void MakeGUI(void)
885 Object
*menu
= MUI_MakeObject(MUIO_MenustripNM
, &nm
, 0);
887 display_hook
.h_Entry
= (HOOKFUNC
)display_func
;
888 construct_hook
.h_Entry
= (HOOKFUNC
)construct_func
;
889 destruct_hook
.h_Entry
= (HOOKFUNC
)destruct_func
;
891 close_hook
.h_Entry
= (HOOKFUNC
)close_func
;
892 front_hook
.h_Entry
= (HOOKFUNC
)front_func
;
893 back_hook
.h_Entry
= (HOOKFUNC
)back_func
;
894 origin_hook
.h_Entry
= (HOOKFUNC
)origin_func
;
895 activate_hook
.h_Entry
= (HOOKFUNC
)activate_func
;
896 zip_hook
.h_Entry
= (HOOKFUNC
)zip_func
;
897 hide_hook
.h_Entry
= (HOOKFUNC
)hide_func
;
898 show_hook
.h_Entry
= (HOOKFUNC
)show_func
;
900 update_hook
.h_Entry
= (HOOKFUNC
)update_func
;
901 rescue_hook
.h_Entry
= (HOOKFUNC
)rescue_func
;
902 showall_hook
.h_Entry
= (HOOKFUNC
)showall_func
;
903 rethink_hook
.h_Entry
= (HOOKFUNC
)rethink_func
;
904 about_hook
.h_Entry
= (HOOKFUNC
)about_func
;
906 openinfo_hook
.h_Entry
= (HOOKFUNC
)openinfo_func
;
907 updateinfo_hook
.h_Entry
= (HOOKFUNC
)update_info_func
;
909 app
= (Object
*)ApplicationObject
,
910 MUIA_Application_Title
, (IPTR
)"WiMP",
911 MUIA_Application_Version
, (IPTR
)version
,
912 MUIA_Application_Copyright
, (IPTR
)"Copyright © 1995-2009, The AROS Development Team",
913 MUIA_Application_Author
, (IPTR
)"The AROS Development Team",
914 MUIA_Application_Description
, (IPTR
)"Window Manipulator",
915 MUIA_Application_Base
, (IPTR
)"WIMP",
916 MUIA_Application_SingleTask
, TRUE
,
917 MUIA_Application_Menustrip
, (IPTR
)menu
,
918 SubWindow
, (IPTR
)(wnd
= (Object
*)WindowObject
,
919 MUIA_Window_Title
, (IPTR
)TITLE_TXT
,
920 MUIA_Window_ID
, MAKE_ID('W', 'I', 'M', 'P'),
921 WindowContents
, (IPTR
)(VGroup
,
922 Child
, (IPTR
)(VGroup
,
923 GroupFrameT("Screen/Window List"),
924 Child
, (IPTR
)(ListviewObject
,
925 MUIA_Listview_List
, (IPTR
)(list_gad
= (Object
*)ListObject
,
927 MUIA_List_Format
, (IPTR
)"BAR,BAR,P=\033c BAR,P=\033c BAR,BAR,BAR",
928 MUIA_List_ConstructHook
, (IPTR
)&construct_hook
,
929 MUIA_List_DestructHook
, (IPTR
)&destruct_hook
,
930 MUIA_List_DisplayHook
, (IPTR
)&display_hook
,
931 MUIA_List_Title
, TRUE
,
935 Child
, (IPTR
)(HGroup
,
936 Child
, (IPTR
)(close_gad
= SimpleButton("\033iKill")),
937 Child
, (IPTR
)(front_gad
= SimpleButton("To _Front")),
938 Child
, (IPTR
)(back_gad
= SimpleButton("To _Back")),
939 Child
, (IPTR
)(origin_gad
= SimpleButton("Move to _Origin")),
940 Child
, (IPTR
)(activate_gad
= SimpleButton("_Activate")),
941 Child
, (IPTR
)(zip_gad
= SimpleButton("_Zip")),
942 Child
, (IPTR
)(hide_gad
= SimpleButton("_Hide")),
943 Child
, (IPTR
)(show_gad
= SimpleButton("_Show")),
945 Child
, (IPTR
)(HGroup
,
946 Child
, (IPTR
)(update_gad
= SimpleButton("_Update List")),
947 Child
, (IPTR
)(rescue_gad
= SimpleButton("_Rescue all Windows")),
948 Child
, (IPTR
)(showall_gad
= SimpleButton("Show all Windows")),
949 Child
, (IPTR
)(rethink_gad
= SimpleButton("Rethink Display")),
950 Child
, (IPTR
)(about_gad
= SimpleButton("About")),
955 SubWindow
, (IPTR
)(info_wnd
= (Object
*)WindowObject
,
956 MUIA_Window_Title
, (IPTR
)INFOTITLE_TXT
,
957 MUIA_Window_ID
, MAKE_ID('W', 'I', 'N', 'F'),
958 WindowContents
, (IPTR
)(page_gad
= (Object
*)PageGroup
,
959 Child
, (IPTR
)(HGroup
,
960 Child
, (IPTR
)(ColGroup(2),
961 GroupFrameT("Screen"),
963 Child
, (IPTR
)Label("Address"),
964 Child
, (IPTR
)(info_scr_addr_gad
= (Object
*)TextObject
,
966 MUIA_Text_Contents
, (IPTR
)"WWWWWWWWWWWWWWWWWWWWWWWWWWWWWW",
967 MUIA_Text_SetMin
, TRUE
,
969 Child
, (IPTR
)Label("LeftEdge"),
970 Child
, (IPTR
)(info_scr_leftedge_gad
= (Object
*)TextObject
, TextFrame
, End
),
971 Child
, (IPTR
)Label("TopEdge"),
972 Child
, (IPTR
)(info_scr_topedge_gad
= (Object
*)TextObject
, TextFrame
, End
),
973 Child
, (IPTR
)Label("Width"),
974 Child
, (IPTR
)(info_scr_width_gad
= (Object
*)TextObject
, TextFrame
, End
),
975 Child
, (IPTR
)Label("Height"),
976 Child
, (IPTR
)(info_scr_height_gad
= (Object
*)TextObject
, TextFrame
, End
),
977 Child
, (IPTR
)Label("Flags"),
978 Child
, (IPTR
)(info_scr_flags_gad
= (Object
*)TextObject
, TextFrame
, End
),
979 Child
, (IPTR
)Label("Title"),
980 Child
, (IPTR
)(info_scr_title_gad
= (Object
*)TextObject
, TextFrame
, End
),
981 Child
, (IPTR
)Label("DefaultTitle"),
982 Child
, (IPTR
)(info_scr_deftitle_gad
= (Object
*)TextObject
, TextFrame
, End
),
983 Child
, (IPTR
)Label("FirstWindow"),
984 Child
, (IPTR
)(info_scr_firstwindow_gad
= (Object
*)TextObject
, TextFrame
, End
),
987 Child
, (IPTR
)(HGroup
,
988 Child
, (IPTR
)(ColGroup(2),
989 GroupFrameT("Window"),
990 Child
, (IPTR
)Label("Address"),
991 Child
, (IPTR
)(info_win_addr_gad
= (Object
*)TextObject
,
993 MUIA_Text_Contents
, (IPTR
)"WWWWWWWWWWWWWWWWWWWWWWWWWWWWWW",
994 MUIA_Text_SetMin
, TRUE
,
996 Child
, (IPTR
)Label("NextWindow"),
997 Child
, (IPTR
)(info_win_nextwin_gad
= (Object
*)TextObject
, TextFrame
, End
),
998 Child
, (IPTR
)Label("LeftEdge"),
999 Child
, (IPTR
)(info_win_leftedge_gad
= (Object
*)TextObject
, TextFrame
, End
),
1000 Child
, (IPTR
)Label("TopEdge"),
1001 Child
, (IPTR
)(info_win_topedge_gad
= (Object
*)TextObject
, TextFrame
, End
),
1002 Child
, (IPTR
)Label("Width"),
1003 Child
, (IPTR
)(info_win_width_gad
= (Object
*)TextObject
, TextFrame
, End
),
1004 Child
, (IPTR
)Label("Height"),
1005 Child
, (IPTR
)(info_win_height_gad
= (Object
*)TextObject
, TextFrame
, End
),
1006 Child
, (IPTR
)Label("MinWidth"),
1007 Child
, (IPTR
)(info_win_minwidth_gad
= (Object
*)TextObject
, TextFrame
, End
),
1008 Child
, (IPTR
)Label("MinHeight"),
1009 Child
, (IPTR
)(info_win_minheight_gad
= (Object
*)TextObject
, TextFrame
, End
),
1010 Child
, (IPTR
)Label("MaxWidth"),
1011 Child
, (IPTR
)(info_win_maxwidth_gad
= (Object
*)TextObject
, TextFrame
, End
),
1012 Child
, (IPTR
)Label("MaxHeight"),
1013 Child
, (IPTR
)(info_win_maxheight_gad
= (Object
*)TextObject
, TextFrame
, End
),
1014 Child
, (IPTR
)Label("Flags"),
1015 Child
, (IPTR
)(info_win_flags_gad
= (Object
*)TextObject
, TextFrame
, End
),
1016 Child
, (IPTR
)Label("IDCMPFlags"),
1017 Child
, (IPTR
)(info_win_idcmp_gad
= (Object
*)TextObject
, TextFrame
, End
),
1018 Child
, (IPTR
)Label("Title"),
1019 Child
, (IPTR
)(info_win_title_gad
= (Object
*)TextObject
, TextFrame
, End
),
1020 Child
, (IPTR
)Label("ReqCount"),
1021 Child
, (IPTR
)(info_win_req_gad
= (Object
*)TextObject
, TextFrame
, End
),
1022 Child
, (IPTR
)Label("WScreen"),
1023 Child
, (IPTR
)(info_win_screen_gad
= (Object
*)TextObject
, TextFrame
, End
),
1024 Child
, (IPTR
)Label("BorderLeft"),
1025 Child
, (IPTR
)(info_win_borderleft_gad
= (Object
*)TextObject
, TextFrame
, End
),
1026 Child
, (IPTR
)Label("BorderTop"),
1027 Child
, (IPTR
)(info_win_bordertop_gad
= (Object
*)TextObject
, TextFrame
, End
),
1028 Child
, (IPTR
)Label("BorderRight"),
1029 Child
, (IPTR
)(info_win_borderright_gad
= (Object
*)TextObject
, TextFrame
, End
),
1030 Child
, (IPTR
)Label("BoderBottom"),
1031 Child
, (IPTR
)(info_win_borderbottom_gad
= (Object
*)TextObject
, TextFrame
, End
),
1032 Child
, (IPTR
)Label("Parent Window"),
1033 Child
, (IPTR
)(info_win_parentwin_gad
= (Object
*)TextObject
, TextFrame
, End
),
1034 Child
, (IPTR
)Label("First Child"),
1035 Child
, (IPTR
)(info_win_firstchild_gad
= (Object
*)TextObject
, TextFrame
, End
),
1036 Child
, (IPTR
)Label("Parent"),
1037 Child
, (IPTR
)(info_win_parent_gad
= (Object
*)TextObject
, TextFrame
, End
),
1038 Child
, (IPTR
)Label("Descendant"),
1039 Child
, (IPTR
)(info_win_descendant_gad
= (Object
*)TextObject
, TextFrame
, End
),
1047 Cleanup(NULL
); // Probably double start
1049 DoMethod(wnd
, MUIM_Notify
, MUIA_Window_CloseRequest
, TRUE
,
1050 app
, 2, MUIM_Application_ReturnID
, MUIV_Application_ReturnID_Quit
);
1052 DoMethod(info_wnd
, MUIM_Notify
, MUIA_Window_CloseRequest
, TRUE
,
1053 info_wnd
, 3, MUIM_Set
, MUIA_Window_Open
, FALSE
);
1055 DoMethod(list_gad
, MUIM_Notify
, MUIA_List_Active
, MUIV_EveryTime
,
1056 (IPTR
)app
, 2, MUIM_CallHook
, (IPTR
)&updateinfo_hook
);
1058 DoMethod(list_gad
, MUIM_Notify
, MUIA_Listview_DoubleClick
, TRUE
,
1059 (IPTR
)app
, 2, MUIM_CallHook
, (IPTR
)&openinfo_hook
);
1063 DoMethod(app
, MUIM_Notify
, MUIA_Application_MenuAction
, MN_QUIT
,
1064 (IPTR
)app
, 2, MUIM_Application_ReturnID
, MUIV_Application_ReturnID_Quit
);
1066 DoMethod(app
, MUIM_Notify
, MUIA_Application_MenuAction
, MN_ABOUT
,
1067 (IPTR
)app
, 2, MUIM_CallHook
, (IPTR
)&about_hook
);
1069 DoMethod(app
, MUIM_Notify
, MUIA_Application_MenuAction
, MN_UPDATE
,
1070 (IPTR
)app
, 2, MUIM_CallHook
, (IPTR
)&update_hook
);
1072 DoMethod(app
, MUIM_Notify
, MUIA_Application_MenuAction
, MN_KILL
,
1073 (IPTR
)app
, 2, MUIM_CallHook
, (IPTR
)&close_hook
);
1075 DoMethod(app
, MUIM_Notify
, MUIA_Application_MenuAction
, MN_FRONT
,
1076 (IPTR
)app
, 2, MUIM_CallHook
, (IPTR
)&front_hook
);
1078 DoMethod(app
, MUIM_Notify
, MUIA_Application_MenuAction
, MN_BACK
,
1079 (IPTR
)app
, 2, MUIM_CallHook
, (IPTR
)&back_hook
);
1081 DoMethod(app
, MUIM_Notify
, MUIA_Application_MenuAction
, MN_ORIGIN
,
1082 (IPTR
)app
, 2, MUIM_CallHook
, (IPTR
)&origin_hook
);
1084 DoMethod(app
, MUIM_Notify
, MUIA_Application_MenuAction
, MN_ACTIVATE
,
1085 (IPTR
)app
, 2, MUIM_CallHook
, (IPTR
)&activate_hook
);
1087 DoMethod(app
, MUIM_Notify
, MUIA_Application_MenuAction
, MN_ZIP
,
1088 (IPTR
)app
, 2, MUIM_CallHook
, (IPTR
)&zip_hook
);
1090 DoMethod(app
, MUIM_Notify
, MUIA_Application_MenuAction
, MN_HIDE
,
1091 (IPTR
)app
, 2, MUIM_CallHook
, (IPTR
)&hide_hook
);
1093 DoMethod(app
, MUIM_Notify
, MUIA_Application_MenuAction
, MN_SHOW
,
1094 (IPTR
)app
, 2, MUIM_CallHook
, (IPTR
)&show_hook
);
1096 DoMethod(app
, MUIM_Notify
, MUIA_Application_MenuAction
, MN_INFO
,
1097 (IPTR
)app
, 2, MUIM_CallHook
, (IPTR
)&openinfo_hook
);
1099 DoMethod(app
, MUIM_Notify
, MUIA_Application_MenuAction
, MN_RESCUE
,
1100 (IPTR
)app
, 2, MUIM_CallHook
, (IPTR
)&rescue_hook
);
1102 DoMethod(app
, MUIM_Notify
, MUIA_Application_MenuAction
, MN_SHOWALL
,
1103 (IPTR
)app
, 2, MUIM_CallHook
, (IPTR
)&showall_hook
);
1105 DoMethod(app
, MUIM_Notify
, MUIA_Application_MenuAction
, MN_RETHINK
,
1106 (IPTR
)app
, 2, MUIM_CallHook
, (IPTR
)&rethink_hook
);
1109 // buttons first row
1110 DoMethod(close_gad
, MUIM_Notify
, MUIA_Pressed
, FALSE
,
1111 (IPTR
)app
, 2, MUIM_CallHook
, (IPTR
)&close_hook
);
1113 DoMethod(front_gad
, MUIM_Notify
, MUIA_Pressed
, FALSE
,
1114 (IPTR
)app
, 2, MUIM_CallHook
, (IPTR
)&front_hook
);
1116 DoMethod(back_gad
, MUIM_Notify
, MUIA_Pressed
, FALSE
,
1117 (IPTR
)app
, 2, MUIM_CallHook
, (IPTR
)&back_hook
);
1119 DoMethod(origin_gad
, MUIM_Notify
, MUIA_Pressed
, FALSE
,
1120 (IPTR
)app
, 2, MUIM_CallHook
, (IPTR
)&origin_hook
);
1122 DoMethod(activate_gad
, MUIM_Notify
, MUIA_Pressed
, FALSE
,
1123 (IPTR
)app
, 2, MUIM_CallHook
, (IPTR
)&activate_hook
);
1125 DoMethod(zip_gad
, MUIM_Notify
, MUIA_Pressed
, FALSE
,
1126 (IPTR
)app
, 2, MUIM_CallHook
, (IPTR
)&zip_hook
);
1128 DoMethod(hide_gad
, MUIM_Notify
, MUIA_Pressed
, FALSE
,
1129 (IPTR
)app
, 2, MUIM_CallHook
, (IPTR
)&hide_hook
);
1131 DoMethod(show_gad
, MUIM_Notify
, MUIA_Pressed
, FALSE
,
1132 (IPTR
)app
, 2, MUIM_CallHook
, (IPTR
)&show_hook
);
1135 // buttons second row
1136 DoMethod(update_gad
, MUIM_Notify
, MUIA_Pressed
, FALSE
,
1137 (IPTR
)app
, 2, MUIM_CallHook
, (IPTR
)&update_hook
);
1139 DoMethod(rescue_gad
, MUIM_Notify
, MUIA_Pressed
, FALSE
,
1140 (IPTR
)app
, 2, MUIM_CallHook
, (IPTR
)&rescue_hook
);
1142 DoMethod(showall_gad
, MUIM_Notify
, MUIA_Pressed
, FALSE
,
1143 (IPTR
)app
, 2, MUIM_CallHook
, (IPTR
)&showall_hook
);
1145 DoMethod(rethink_gad
, MUIM_Notify
, MUIA_Pressed
, FALSE
,
1146 (IPTR
)app
, 2, MUIM_CallHook
, (IPTR
)&rethink_hook
);
1148 DoMethod(about_gad
, MUIM_Notify
, MUIA_Pressed
, FALSE
,
1149 (IPTR
)app
, 2, MUIM_CallHook
, (IPTR
)&about_hook
);
1151 set(wnd
, MUIA_Window_Open
, TRUE
);
1152 CallHookPkt(&update_hook
, 0, 0);
1153 CallHookPkt(&updateinfo_hook
, 0, 0);
1154 DoMethod(app
, MUIM_Application_Execute
);
1157 /*********************************************************************************************/
1159 static void Cleanup(CONST_STRPTR txt
)
1161 MUI_DisposeObject(app
);
1164 MUI_Request(app
, wnd
, 0, TITLE_TXT
, "OK", txt
);
1170 /*********************************************************************************************/
1172 int main(int argc
, char **argv
)