home *** CD-ROM | disk | FTP | other *** search
- #include <string.h>
-
- #include "DeskLib:Menus.h"
- #include "DeskLib:WimpSWIs.h"
- #include "DeskLib:Kbd.h"
- #include "DeskLib:Window.h"
- #include "DeskLib:Event.h"
- #include "DeskLib:Save.h"
-
- #include "Shell.ShellMenu.h"
- #include "Shell.Extra.h"
-
-
-
- #define Shell_StringsDiffer( s1, s2) (strcmp( (s1), (s2)))
- #define Shell_StringsEqual( s1, s2) (!strcmp( (s1), (s2)))
- /* I can never remember which way round strcmp works... */
-
- BOOL Shell_pause = FALSE;
-
- static char Shell_selections[255];
- static menu men, defaultmenu;
- static menu_block *menublock;
- static Shell_menuhandler menuhandler;
-
- static window_handle save_window;
-
-
-
-
- void Shell_MenuPoll( void)
- {
- do {
- if ( Shell_pause) Shell_Poll();
- else {
- Shell_PollSlow();
- if ( !Shell_selections[0]) return;
- }
-
- if ( Shell_selections[0]) {
- if ( Shell_StringsEqual( Shell_selections, "Pause")) {
- Shell_pause=TRUE;
- }
- else if ( Shell_StringsEqual( Shell_selections, "Continue")) {
- Shell_pause=FALSE;
- }
- else menuhandler( Shell_selections);
- Shell_selections[0] = 0;
- }
- }
- while ( Shell_pause);
- }
-
-
-
-
-
-
-
- static void Shell_MenuHandler( void *ref, int *hit)
- {
-
- UNUSED( ref);
-
- Wimp_DecodeMenu( menublock, hit, Shell_selections);
- *strchr( Shell_selections, '\r') = 0;
- /* can't do 'menuhandler( Shell_selections)' */
-
- if ( Shell_StringsEqual( Shell_selections, "Pause")) {
- Menus_SetFlags( men, 1, TRUE, TRUE);
- Menus_SetFlags( men, 2, FALSE, FALSE);
- }
-
- else if ( Shell_StringsEqual( Shell_selections, "Continue")) {
- Menus_SetFlags( men, 1, FALSE, FALSE);
- Menus_SetFlags( men, 2, TRUE, TRUE);
- }
-
- /* copy hit to global storage, so that menu flags can be changed (NIY)
- { int *hit2 = global_hit;
- do {
- *hit2++ = *hit++;
- }
- while ( *hit != -1);
- }
- */
- }
-
-
-
-
-
-
-
-
- static menu Shell_MenuMaker( void *ref)
- {
- /*if ( Kbd_KeyDown( inkey_SHIFT)) return (menu) -1;*/
- UNUSED( ref);
- return men;
- }
-
-
-
-
-
-
- void Shell_InitMenuHandler( char *menutitle, char *menustring, Shell_menuhandler menhand)
- {
- men = Menus_New( menutitle, menustring);
-
- defaultmenu = Menus_New( "Default", "Save");
-
- save_window = Window_Create( "SaveAs", 0);
-
- Menus_AddDialogBox( defaultmenu, 1, save_window);
-
- Menus_SetFlags( men, 1, FALSE, FALSE);
- Menus_SetFlags( men, 2, TRUE, TRUE);
-
- menublock = Menus_SysHandle( men);
- Menus_AttachMenuMaker( Shell_MenuMaker, event_ANY, event_ANY, Shell_MenuHandler, (void *) men );
- menuhandler = menhand;
- }
-
-
-
- void Shell_ChangeMenu( char *menutitle, char *menustring)
- {
- /*Menus_Dispose( men, |*recursive*| TRUE);*/
- men = Menus_New( menutitle, menustring);
- defaultmenu = Menus_New( "default", "Save");
- menublock = Menus_SysHandle( men);
- Menus_AttachMenu( men, event_ANY, event_ANY, Shell_MenuHandler, NULL );
- }
-
-
- void Shell_SuspendMenu( void)
- {
- if (!men) Shell_ErrorReportFatal( 1, "Can't suspend menu - none is defined");
- Menus_DetachMenu( event_ANY, event_ANY);
- }
-
-
- void Shell_UnSuspendMenu( void)
- {
- Menus_AttachMenu( men, event_ANY, event_ANY, Shell_MenuHandler, NULL );
- }
-
-
-