/*  Local Functino Prototypes And Data */
     
	struct 	ObjApp *App;
extern void Handle_MainWindow_Input( int );
extern void Handle_Task_Input( int );
extern void Handle_Dissassembler_Input( int );

/*  End of Local Function Prototype And Data */


/*
      ##   ##    ##    #  ##   #  #
      # # # #   #  #   #  # #  #  #
      #  #  #   ####   #  #  # #  #     
      #     #  #    #  #  #   ##     
      #     #  #    #  #  #    #  #
      _____________________________
 */



/* The Plan */
/*

struct Module = 
{
  char[5]   Module_ID = "SOMA";					//To Show Is A SOMA Module!
  int       CheckSum  = 0;					//The CheckSum of Module To Stop Lamers
  char[32]  Version   = "FrontEnd V1.0 - 9/7/95 By Cray-1";	//A VER$
  
  



 StartMUI();
 OpenPort("MESSAGE_P");
 Find_Module_Path();
 Check_Modules(ALL);
 OpenModule(FRONTEND);





OpenModule();
{
 

  1) MUi Will start, and Initialise
  2) A Public Port Will Be Started For Modules To Talk To Each Other.
  3) The Program Will Then Check Its Preferences For Module Paths Than Things.
  4) The Progam Will Go Down The Module List Checking They Are Valid Modules.
  5) It Will Then Run A Module Called FRONTEND
      >> 














main( void )
{
        Open_Librarys(); 
     
    App = CreateApp();
    if(App)
     {        
       DoMethod(App->MainWindow_Task_List,MUIM_List_Clear);
       set(App->MainWindow_Task_List,MUIA_List_Quiet,TRUE);
       Tasks_Display();
       set(App->MainWindow_Task_List,MUIA_List_Quiet,FALSE); 
       Input_Handler();       
       Free_Memory();
     }
     else
     {
        printf("Failed To Create The Application\n");
     }
    Close_Librarys();
}






void Input_Handler( void )
{
  
  ULONG signals;
  BOOL running = TRUE;
  BOOL *Active = FALSE;
  ULONG Fred;

  struct Task *Selected_Task;
  Selected_Task = AllocRemember(&General_Memory,sizeof(struct Process),MEMF_CLEAR);


    while (running)
      {
         switch (Fred = DoMethod(App->App,MUIM_Application_Input,&signals))
             {
                   case MUIV_Application_ReturnID_Quit:
                           running = FALSE;
                         break;
                         
                   case ID_MainWindow_CloseRequest:
                           running = FALSE;
                         break;
             }
         get(App->Main_Window,MUIA_Window_Activate,&Active);
         if(Active)
             {
              Handle_MainWindow_Input(Fred);
             }
             else
             {
              get(App->Task_Info_Window,MUIA_Window_Activate,&Active);
              if(Active)
                {
                 Handle_Task_Input(Fred);
                } 
                else
                {
                 get(App->Dissassembler_Window,MUIA_Window_Activate,&Active);
                 if(Active)
                   {
                    Handle_Dissassembler_Input(Fred);
                    }
                    else
                    {
                        
                    }
                
                }
             }
         if (running && signals) Wait(signals);
      }

     
     DoMethod(App->MainWindow_Task_List,MUIM_List_Clear);   
     if(Memory!=0)
        {
         sprintf((char *)Selected_Task,"%d Bytes\n%d - Construct/Destruct Ratio.",Memory,Display_Count);        
         MUI_Request(App->App,App->Main_Window,0,"Memory Problem","*_Ohh God","Memory Allocated Is Not Free.\n\33c\33b%s",Selected_Task); 
        }
   DisposeApp(App);
}




void Handle_MainWindow_Input( int Main_Message)
{
    int Message;
    
        switch(Main_Message)
               {
                 
                  case MainWindow_TerminateTask:                       
                          get(App->Registered_Pages_Group,MUIA_Group_ActivePage,&Message);
                          switch(Message)
                           {
                              case 0:		// Task Page
                                   Terminate_Task();
                                 break;

                              case 1:		// Vector Page

                                 break;
                            
                           }
                       break;
                       
                  case MainWindow_InfoTask:
                  Start_Dissassembler( 0x9CA, 100,"");
                  
                              //Information_Task();
                          break;
                              
                  case MainWindow_ChangeActive:	
                          get(App->Registered_Pages_Group,MUIA_Group_ActivePage,&Message);                       
                          switch(Message)
                                {
                                   case MainWindow_ActTaskPage:
                                           DoMethod(App->MainWindow_Task_List,MUIM_List_Clear);
                                           set(App->MainWindow_Task_List,MUIA_List_Quiet,TRUE);
                                           Tasks_Display();
                                           set(App->MainWindow_Task_List,MUIA_List_Quiet,FALSE);
                                        break;

                                   case MainWindow_ActVectorPage:                                 
                                        break;
                        
                                   case MainWindow_ActWindowPage:
                                        break;
                        
                                   case MainWindow_ActPortPage:
                                         break;                          
                           
                                   case MainWindow_ActSemaphorePage:
                                        break;
                               }
                        break;                       
              }
 
}


