#include "starappl.h"
#include <gui/button.h>
#include "starfsel.h"
#include <gui/window.h>
#include <gui/menu.h>
#include <gui/frame.h>
#include <gui/messageb.h>
#include <struc/starpasr.h>
#include <struc/pasrmain.h>


void main ( unsigned int argc, char **argv )
{
  id app, MainWindow, MainMenu, FileMenu, OpenFileMenu, ViewMenu, 
  HelpMenu, OpenFileHelpMenu, aFrame, FileButton, ViewButton, HelpButton, 
  OpenFileButton, OpenDictionButton, OpenSTARButton, QuitButton, 
  GeneralHelpButton, OpenFileHelpButton, 
  aFileSelector, aDictionSelector, HelpBox;

  // the following variable is needed by the lexer.
  progName=*argv;

  app=[[WDCSTARApplication alloc] initWithName:"Application"];
  [app setSTARParser:[WDCStarParser alloc]];

  MainWindow=[[WDCWindow alloc] initWithName:"MainWindow" managedBy:app];
  [MainWindow setArg:"width" to:(void*)300];
  [MainWindow setArg:"height" to:(void*)300];
  
  MainMenu=[[WDCMenu alloc] 
	    initWithName : "MainMenu" managedBy : MainWindow];
  
  FileButton=[[WDCCascadeButton alloc] 
	      initWithName : "File" managedBy : MainMenu];
  FileMenu=[[WDCMenu alloc] 
	    initWithName : "FileMenu" managedBy : FileButton];
  OpenFileButton=[[WDCCascadeButton alloc] 
		  initWithName : "Open a File" managedBy : FileMenu];
  OpenFileMenu=[[WDCMenu alloc] 
		initWithName : "OpenFileMenu" managedBy : OpenFileButton];
  OpenDictionButton=[[WDCPushButton alloc] 
		     initWithName : "Dictionary" 
		     managedBy : OpenFileMenu];
  [[[WDCSTARFileSelectBox alloc] 
    initWithName : "DictionarySelector" managedBy : OpenDictionButton]
   setActionMessage : "parseDictionary:"];
  OpenSTARButton=[[WDCPushButton alloc] 
		  initWithName : "STAR File" 
		  managedBy : OpenFileMenu];
  [[[WDCSTARFileSelectBox alloc]
    initWithName : "StarFileSelector" managedBy : OpenSTARButton]
   setActionMessage : "parseStarFile:"];
  QuitButton=[[WDCQuitButton alloc] managedBy:FileMenu];
  
  ViewButton=[[WDCCascadeButton alloc] 
	      initWithName : "View" managedBy : MainMenu];
  [ViewButton setArg:XmNsensitive to:(char*)False];
  
  HelpButton=[[WDCCascadeButton alloc] 
	      initWithName : "Help" managedBy : MainMenu];
  HelpMenu=[[WDCMenu alloc] 
	    initWithName : "HelpMenu" managedBy : HelpButton];
  GeneralHelpButton=[[WDCPushButton alloc] 
		     initWithName : "General" managedBy : HelpMenu];
  HelpBox=[[WDCHelpMessageBox alloc] managedBy:GeneralHelpButton];
  [HelpBox setMessage:"A generic help message will appear here."];
  OpenFileHelpButton=[[WDCCascadeButton alloc]
		      initWithName : "Open a file" managedBy : HelpMenu];
  OpenFileHelpMenu=[[WDCMenu alloc] 
		    initWithName : "OpenFileHelpMenu" 
		    managedBy : OpenFileHelpButton];
  [[[WDCHelpMessageBox alloc] managedBy:[[WDCPushButton alloc] 
					 initWithName : "Open a dictionary" 
					 managedBy : OpenFileHelpMenu]] 
   setMessage : "This is a help for opening a dictionary. \n"];
  [[[WDCHelpMessageBox alloc] managedBy:[[WDCPushButton alloc] 
					 initWithName : "Open a STAR file" 
					 managedBy : OpenFileHelpMenu]] 
   setMessage : "This is a help for opening a STAR file. \n"];
  /*
     MainFrame=[[WDCFrame alloc] 
     initWithName : "MainFrame" managedBy : MainWindow];
     [MainFrame setArg:"width" to:(void*)300];
     [MainFrame setArg:"height" to:(void*)300];
     */
  /*
     XmMainWindowSetAreas([MainWindow getWidget],
     [aMenu getWidget],
     NULL,
     NULL,
     NULL,
     [aFrame getWidget]);
     */

  [app run];  
}




