#include "appl.h"
#include "button.h"
#include "filesele.h"
#include "window.h"
#include "menu.h"
#include "frame.h"
#include "messageb.h"
#include "popupbox.h"
#include "popupshl.h"
#include "form.h"
#include "separato.h"

void main ( unsigned int argc, char **argv )
{
  id app, MainWindow, MessageWindow,
  MainMenu, FileMenu, EditMenu, HelpMenu, 
  OpenFileHelpMenu, RadioBox, aFrame, 
  FileButton, EditButton, HelpButton, 
  OpenFileButton, QuitButton, button1, button2,
  GeneralHelpButton, OpenFileHelpButton, OpenToggleButton, 
  aFileSelector, HelpBox,
  RowCol, form, drawBox;


  app=[[WDCApplication alloc] initWithName:"Application",argc, argv];
  MainWindow=[[WDCWindow alloc] initWithName:"MainWindow" managedBy:app];

  [MainWindow setArg:XmNwidth to:(char*)200];
  [MainWindow setArg:XmNheight to:(char*)200];
  
  MessageWindow=[[WDCWindow alloc] 
	       initWithName : "MainWindow" managedBy : MainWindow];
  [MessageWindow setArg:"width" to:(void*)800];
//  [MainWindow setArg:XmNmessageWindow to:(char*)MessageWindow];
  [MainWindow setArg:XmNshowSeparator to:(char*)True];
  MainMenu=[[WDCMenu alloc] initWithName : "MainMenu" 
	    managedBy : MainWindow];
  FileButton=[[WDCCascadeButton alloc] 
	      initWithName : "File" managedBy : MainMenu];
  EditButton=[[WDCCascadeButton alloc] 
	      initWithName : "Edit" managedBy : MainMenu];
  HelpButton=[[WDCCascadeButton alloc] 
	      initWithName : "Help" managedBy : MainMenu];
  HelpMenu=[[WDCMenu alloc] 
	    initWithName : "HelpMenu" managedBy : HelpButton];
  GeneralHelpButton=[[WDCPushButton alloc] 
		     initWithName : "General" managedBy : HelpMenu];
  OpenFileHelpButton=[[WDCCascadeButton alloc]
		      initWithName : "Open a file" managedBy : HelpMenu];
  OpenToggleButton=[[WDCPushButton alloc] 
		    initWithName : "Open Toggle" managedBy : HelpMenu];
 
  RadioBox=[[WDCCheckBox alloc] 
	    initWithName : "Row Column" managedBy : OpenToggleButton];
  [RadioBox setArg:XmNx to:(char*)100];
  [RadioBox setArg:XmNy to:(char*)100];

  [[WDCToggleButton alloc] initWithName : "toggle1" managedBy : RadioBox];
  [[WDCToggleButton alloc] initWithName : "toggle2" managedBy : RadioBox];
  [[WDCToggleButton alloc] initWithName : "toggle3" managedBy : RadioBox];
//  [[WDCSeparator alloc] initWithName : "separator" managedBy : RadioBox];
  [[[WDCToggleButton alloc] 
    initWithName : "toggle4" 
    managedBy : RadioBox] setArg:XmNsensitive to:(char*)False];
  
  [[[WDCToggleButton alloc] 
    initWithName : "toggle5" 
    managedBy : RadioBox] setArg:XmNvisibleWhenOff to:False];
  [[WDCToggleButton alloc] initWithName : "toggle6" managedBy : RadioBox];

//  MainWindow=[[WDCFrame alloc] initWithName:"Window" managedBy :MessageWindow];

  RadioBox=[[WDCCheckBox alloc] 
	    initWithName : "Row Column" 
	    managedBy : MessageWindow];

//  [RadioBox manage];
  drawBox=[[[[WDCDrawBox alloc] initWithName:"Draw" managedBy:
    [[WDCToggleButton alloc] initWithName:"toggle1" managedBy:RadioBox]]
    setArg :"width" to:(char*)200] setArg :"height" to:(char*)200];
  [[WDCToggleButton alloc] initWithName:"toggle2" managedBy:RadioBox];
  [[WDCToggleButton alloc] initWithName:"toggle3" managedBy:RadioBox];
  [[WDCToggleButton alloc] initWithName:"toggle4" managedBy:RadioBox];
  [[WDCToggleButton alloc] initWithName:"toggle5" managedBy:RadioBox];
  [[WDCToggleButton alloc] initWithName:"toggle6" managedBy:RadioBox];

//  I don't know why this does not work.
// 
//  [[[[WDCPushButton alloc] initWithName:"Clear" managedBy:drawBox]
//    setActionMessage :"clear"] setActionMessageReceiver:drawBox];
//

  [[[drawBox getDrawArea] setArg :"width" to:(char*)400] 
   setArg :"height" to:(char*)500];
   
  
  
  FileMenu=[[WDCMenu alloc] 
	    initWithName : "FileMenu" managedBy : FileButton];
  OpenFileButton=[[WDCPushButton alloc] 
		  initWithName : "Open" managedBy : FileMenu];
  aFileSelector
    =[[WDCFileSelectBox alloc] 
      initWithName : "FileSelector" managedBy : OpenFileButton];
  QuitButton=[[WDCQuitButton alloc] managedBy:FileMenu];
  HelpBox=[[WDCHelpMessageBox alloc] managedBy:GeneralHelpButton];
  [HelpBox setMessage:"A generic help message will appear here."];

  OpenFileHelpMenu=[[WDCMenu alloc] 
		     initWithName : "OpenFileHelpMenu" 
		     managedBy : OpenFileHelpButton];
  button1=[[WDCPushButton alloc] 
	   initWithName : "Test1" managedBy : OpenFileHelpMenu];
  button2=[[WDCPushButton alloc] 
	   initWithName : "Test2" managedBy : OpenFileHelpMenu];
  [button2 setActionMessage:"toggleManagedState" withReceiver:MessageWindow];
  HelpBox=[[WDCHelpMessageBox alloc] managedBy:button1];
  [HelpBox setMessage:"A generic help message will appear here."];

  [app run];  
}



